Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
8,827 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.