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 trialHelen Wang
2,215 PointsCannot get the response "Sold!" and decrement the tickets remaining
Not sure what went wrong with my code
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 the screen "SOLD!" to confirm purchase
print("SOLD!")
#and then decrement the tickets remaining by the number of tickets purchased
tickets_remaining -= num_tickets
#Otherwise...
else:
#Thank they by name
print("Thank you anyway,{}!".format(name))
1 Answer
John Lack-Wilson
8,181 PointsHey Helen, it seems as if this might not be all of your code? If so, could you please post the remainder of it so we can see if there are different issues.
Here are the issues I can see from this snippet:
- tickets_remaining hasn't been assigned a value before you try to decrement it
- num_tickets hasn't been assigned a value
- name hasn't been assigned a value
The above may not be related to the issues you're having but without seeing all of your code it is hard to tell.