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 All Together Now Gather Information

i keep getting a syntax error and i need help!

i copied the code just like the video but for some reason mine doesnt work please help

# promt user if they want to proceed. Y/N
should_proceed = input("do you want to proceed?  Y/N  "
# if they want to proceed 
if should_proceed.lower() == "y":
  #print to the screen "SOLD!" to confirm purchase 
    print("SOLD!")

ERROR MSG:

treehouse:~/workspace$ python masterticket.py                                                                                                                                                                                                  
  File "/home/treehouse/workspace/masterticket.py", line 23                                                                                                                                                                                    
    if should_proceed.lower() == "y":                                                                                                                                                                                                          
                                                         ^                                                                                                                                                                                                          
SyntaxError: invalid syntax

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Jayden Smith :smiley: I've answered your question over in the Techdegree slack channels. But for anyone reading this post, there was a closing parenthesis missing on the preceding line with input().

You originally had:

should_proceed = input("do you want to proceed? Y/N "

instead of:

should_proceed = input("do you want to proceed? Y/N ")  #  closing parenthesis added

Glad you got it figured out! :sparkles:

I spot one issue right off the bat.

This

should_proceed = input("do you want to proceed? Y/N "

is missing the closing ")"

This code works (I tested it on my local system):

# Prompt user if they want to proceed.  Y/N?
should_proceed = input("Do you want to proceed?  Y/N  ")

# if they want to proceed
if should_proceed.lower() == "y":
    # print out to screen "Sold!" tp confirm purchase
    print("Sold!")

although, I would actually prefer to code it like this:

# Prompt user if they want to proceed.  Y/N?
should_proceed = input("Do you want to proceed?  Y/N  ").lower()

# if they want to proceed
if should_proceed == "y":
    # print out to screen "Sold!" tp confirm purchase
    print("Sold!")

It's a subtle difference, but I think it makes the if statement more readable and both code snippets have essentially the same functionality.

I hope that helps. Happy coding!