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 trialJayden Smith
Python Development Techdegree Student 498 Pointsi 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
Treehouse TeacherHi there, Jayden Smith 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!
Peter Vann
36,427 PointsI 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!