Im in a beinning programming class and i have a tax program to make in pything, i have it working but for some reason, the If else statement is triggering the calculations after the if when it should end when just printing. Here is my code
taxr = 0.2#Sets the default tax rate
stdded = 10000 # sets the standard deduction
depded = 2000 # sets the dependent deduction
income = int(input("Enter your income: ")) # User input's their income
if income<20000: print('Your income is not taxable') # If income is less that 20000 it ends
else: dep = int(input('Enter how many dependants you have: '))# Collects the number of dependants if needed
dedincome = income - stdded - (depded*dep) # Calculates the Income after deductions
incometax = dedincome * taxr # Calculates the amount of income tax taken out
gross = income - incometax # Calculates the gross and final income
print();#prints the tax information
print('Your income tax is $',incometax)
print('Your income after tax is $',gross)
The If is less than 20 should just print you dont get taxed but it is printing that then i get a error Traceback (most recent call last): File "filepath redacted/Lab6.py", line 7, in dedincome = income - stdded - (depded*dep) # Calculates the Income after deductions NameError: name 'dep' is not defined
I have tried indenting the lines, becasue its continueing to line 7 when it shouldnt, ive also looked for maybe a end command to put in place on line 5 but i cannot find anything.