Python Python Basics Functions and Looping Raising Exceptions

Luke Tate
seal-mask
.a{fill-rule:evenodd;}techdegree
Luke Tate
Python Development Techdegree Student 901 Points

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 "

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

2 Answers

ThatOneCoder -
ThatOneCoder -
6,648 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))

ThatOneCoder -
ThatOneCoder -
6,648 Points

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