I'm needing help on getting the loop in my function Deductions to work.
I've tried looking through similar problems on stackoverflow but struggling to get my head around them.
def Deductions(money, Tax, TotalInsurance):
deductions = 0
global TotalDed
TotalDed = 0
choice = ""
while not choice == "Y" or choice == "N":
try:
choice = str(input("Do you want to add any more deductions to your income, e.g car, rent or mortgage? Y/N : "))
except ValueError:
print("Must enter Y or N")
if choice == "Y":
while choice == "Y":
AddDed = int(input("How much would you like to deduct: "))
deductions = AddDed + deductions
loop = str(input("Would you like to add more deductions? Y/N: "))
if loop == "Y":
choice == "Y"
elif loop == "N":
choice =="N"
elif choice == "N":
TotalDed = TotalTax + deductions
print("Income: £", money)
print("Taxed: £", Tax)
print("National Insurance: £", TotalInsurance)
print("Other Deductions: £", deductions)
print("Total Deductions: £", TotalDed)
return TotalDed
I'm wanting to make sure that my loop only accepts "Y" and "N". then to proceed to ask for Deductions.