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 trialLuke Tate
Courses Plus Student 2,256 PointsWhy do I keep getting End of File parsing errors, when raising exceptions?
Here is the code from the video I was following:
def split_check(total, number_of_people): if number_of_people <= 1: raise ValueError("More than 1 person is required to split the check")
return math.ceil(total/number_of_people)
try:
total_due = float(input("What is the total? "))
number_of_people = int(input("How many people? "))
amount_due = split_check(total_due, number_of_people)
except ValueError as err:
print("Oh no! That's not a valid value. Try again...")
print("({})".format(err))
else:
In the console when I type python and the file's name, this message keeps occurring: "File "Functions.py", line 55
SyntaxError: unexpedcted EOF while parsing "
2 Answers
ThatOneCoder -
9,310 PointsWell I don't see the problem in your code so here is mine,
import math
def split_check(total, number_of_people):
if number_of_people <= 1:
raise ValueError("More than 1 person is required to split the check")
return math.ceil(total / number_of_people)
try: total_due = float(input("Whats the cost? ")) number_of_people = int(input("How many people? ")) amount_due = split_check(total_due, number_of_people) except ValueError as err: print("Oh no! That's not a valid value! Try again...") print("({})".format(err)) else: print("Each person owns ${}".format(amount_due))
Luke Tate
Courses Plus Student 2,256 PointsThank you! I believed that last print function just fixed it.
ThatOneCoder -
9,310 PointsDid you import math??? That may be the problem.
Luke Tate
Courses Plus Student 2,256 PointsI have already did that twice. I'm still get that same error.
boi
14,242 Pointsboi
14,242 PointsYour problems will be solved in this video >>> click here