Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with print error
#1
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)
Reply
#2
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
Reply
#3
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)
Output:
6505.143508027656
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Print Error DaveG 1 1,062 Apr-07-2022, 03:10 AM
Last Post: deanhystad
  Error with print and return commands TheDark_Knight 2 1,894 Jan-15-2020, 04:59 PM
Last Post: TheDark_Knight
  I am getting an Error, and not sure why? My goal is to print out rahulne22 7 2,978 Dec-01-2019, 03:53 PM
Last Post: snippsat
  Error in print statment leodavinci1990 1 1,897 Jul-21-2019, 04:46 AM
Last Post: buran
  Why do i have invalid syntax on a line after print, i see no error ? iofhua 5 2,875 May-24-2019, 05:42 PM
Last Post: Yoriz
  Attribute error print statement error jamshaid1997 1 2,427 Jan-20-2019, 04:02 PM
Last Post: ichabod801
  Only one of two lines print/syntax error naysjp 2 3,685 Jan-12-2017, 07:08 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020