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 trialMatthew Sylvester
297 Pointserror when checking if input == "yes"
I don't know what I'm doing wrong here. When I check if they want to add a name to a list I check if the answer given is yes and it gives me an invalid syntax error right at the end of the line.
sets answer input to variable answer
problematic code: if answer == "yes" (then I prompt for name input and push onto roster list) I'm getting an error at the end of "yes"
I don't know how else to check if the first question (unlisted here) is answered by "yes". (first question is whether they want to add a player to the roster).
2 Answers
Matthew Sylvester
297 PointsAdding the colon got me beyond that error. Thanks!
ygh5254e69hy5h545uj56592yh5j94595682hy95
7,934 PointsI don't see you full code, thus I'm unable to see why you are getting that error. Perhaps you have missed an ':' at the end of 'yes'.
Anyways, here is an example that works, take a look at it and compared it to your code. If you need further help, please post your full code.
Good luck.
answer = input('Would you like to add a name to the roster? ')
if answer == 'yes':
print('Adding name to roaster')