Python Forum

Full Version: Annuity function for school - syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Basic question but I`m doing something wrong. When run (windows idle 3.8) I receieve name 'a' is not defined. Thanks for help.

def instalment(a,b,c):
return (a*(b/100/12))/(1-(1+(b/100/12)**-c))
a = int(input("loan amount:"))
b = int(input("annual interest rate:"))
c = int(input("repayment period in months:"))
print("Monthly instalment equals to:", instalment(a,b,c))
I don't think so.  I just ran the code on windows using the same version of IDLE without an error.  The result is wrong because there is an error in the instalment calculation.  You should also allow entering a fractional interest rate.
Unless, since indentation is lost, you have the line 
a = int(input("loan amount:"))
indented. If that is true it will be considered part of the function, so your call in the line that calls the function will not have  a value for a
Can't wait for them to fix the python tags....