Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDEVIN ANDERSON
Courses Plus Student 713 Pointshave copied line for line and running into same error on line 9
Hi Guys, This is driving me nuts:
import math
def split_check(total, number_of_people):
return math.ceil (total / number_of_people)
try:
total_due = float(input( "What is the amount? ")
number_of_people = int(input("How many People? "))
except ValueError:
print( "Oh no! That's not a valid value. Try again...")
else:
amount_due= split_check(total_due, number_of_people)
print("Each person owes ${}.format(amount_due))
I have literally copied line for line what is in the video and can't get the same result it always says:
treehouse:~/workspace$ python check_please_3
File "check_please_3", line 9
number_of_people = int(input("How many People? "))
^
SyntaxError: invalid syntax
[MOD: added ```python formatting. -cf]
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYou have a typo:
total_due = float(input( "What is the amount? ") # Missing closing paren
The stack trace output points at the number_of_people
reference in line 9 because the missing paren causes the statement defining number_of_people
to be absorbed in the float()
function call. Missing parens and missing or mismatched quotation marks cause the stack trace to report misleading error messages. The error can be many lines above the reported error line.
Post back if you need more help. Good Luck!
Guilherme Mergulhao
4,002 PointsAlso, the last line of code is missing closing double quotes.
Best Regards,
Chris Freeman
Treehouse Moderator 68,441 PointsGood catch!