Shamus Chowenhill Shamus Chowenhill - 3 months ago 5
Python Question

I keep getting a syntax error, somehow due to the colon at the end of a function definition

I'm brand new to python, and programming in general, so this is probably something extremely simple, but I'm persistently getting this syntax error at the end of the line defining my function for minPayment. I can't see any problem with it... here is the program so far.

Problem set 1: credit card balance calculator

print 'Month 1'
OutstandingBalance = raw_input(float('enter your balance'))
AnnualInterestRate = raw_input(float('enter rate as a decimal(%/100)'))
MinimumMonthlyPaymentRate = raw_input(float('enter minimum monthly payment rate as a decimal(%/100)'))
def minPayment:
minPayment = MinimumMonthlyPaymentRate * OutstandingBalance
print 'minimum payment='minPayment
return minPayment
def accIntrst:
accIntrst = (AnnualInterestRate/12.0) * OutstandingBalance
print 'accrued interest = 'accIntrst
return accIntrst
def balPaid:
balPaid = accIntrst - minPayment
print 'balance paid = 'balPaid
return balPaid
def remBal:
remBal = OutstandingBalance - balPaid
print 'remaining balance = 'remBal
return remBal

Any feedback is greatly appreciated!


Add parentheses to your functions. Python syntax dictates so.

So, instead of def minPayment:, write def minPayment(): instead.