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 trial

Python Python Basics Functions and Looping Raising Exceptions

Why 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 "

boi
boi
14,242 Points

Your problems will be solved in this video >>> click here

2 Answers

ThatOneCoder -
ThatOneCoder -
9,310 Points

Well 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))

Thank you! I believed that last print function just fixed it.

ThatOneCoder -
ThatOneCoder -
9,310 Points

Did you import math??? That may be the problem.

I have already did that twice. I'm still get that same error.