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


Grant Barnhart
Grant Barnhart
1,811 Points

Syntax error check_please.py but the code matches the instructors?


<import math>

<def split_check(total, number_of_people):>
    <p>if number_of_people <= 1:</p>
        <p>raise ValueError("More than 1 person is needed to split a check!")</p>
    <p>return math.ceil(total / number_of_people)</p>

    <p>total_due = float(input("What is the total?   "))</p>
    <p>number_of_people = int(input("How many people?   "))</p>
    <p>amount_due = split_check(total_due, number_of_people)</p>
<except ValueError as err:>
    <p>print("Numbers, you fool!")</p>
    <print("Each person owes ${}".format(amount_due))>


No matter how I indent or change it up, I continue to get a syntax error on line 15, the else at the bottom. My code matches the instructors' code exactly, and his runs, yet I get:

File "check_please.py", line 15
SyntaxError: invalid syntax

I've run it in the cmd line of my computer and it says the same thing. Very frustrating...


Edit: I've tried multiple times to get the code to read right, but it's not working right for me, or I'm doing something wrong. Is there an EASY way to post code on here?

Grant Barnhart
Grant Barnhart
1,811 Points

Forgot to close the print function


1 Answer

Elias Flores
Elias Flores
905 Points

Hello Grant, you are doing a very good job.

The real error is on line 14:


It seems you forgot to close the print() function call since it doesn't have the closing parenthesis that correspond to it.

Don't let this discourage you, errors happens all the time to every programmer!

Grant Barnhart
Grant Barnhart
1,811 Points

Yeah, I looked it over about 100 times and missed it every time. Thanks!