Need help with print error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Need help with print error (/thread-17754.html) |
Need help with print error - newbiepy - Apr-22-2019 Hello all. I'm totally new into Python learning journey and am stuck here, any thoughts what I'm missing here? I'm getting error with print saying invalid syntax loan = 100000 interest = 0.05 pn = 30 monthlypayment = loan[interest(1+interest)(pn)/[(1+interest)(pn)-1] #print(monthlypayment) RE: Need help with print error - SheeppOSU - Apr-22-2019 The "[]" are usually used to call upon stuff from lists and dicts, that is most likely the syntax. Also if you are trying to multiply the variables, use "*". That is what's probably also giving you a syntax error RE: Need help with print error - Yoriz - Apr-22-2019 There is uneven open to close [] giving a invalid syntax, () & [] in python do special things you cant just copy a maths formula M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1] as close as you can.loan = 100000 interest = 0.05 pn = 30 # monthlypayment = loan[interest(1+interest)(pn)/[(1+interest)(pn)-1] # M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1] monthlypayment = loan * (interest * (1 + interest) ** pn) / ((1 + interest) ** pn - 1) print(monthlypayment)
|