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 trialHarm Moolenaar
1,733 PointsMy tickets remaining stays at 100
Heres my code
TICKET_PRICE = 10
user_name = input("What is your name? ")
tickets_remaining = 100
while tickets_remaining >= 1:
print("there are {} tickets remaining".format(tickets_remaining))
ticket_amount = input("Howmany tickets would you like? ")
ticket_amount = int(ticket_amount)
ticket_price_total = (TICKET_PRICE * ticket_amount)
print("The total price is {}".format(ticket_price_total))
proceed_ans = input("Would you like to proceed? Y/N? ")
if proceed_ans.lower == "y":
print("sold!")
tickets_remaining = (tickets_remaining - ticket_amount)
else:
print("bummer, {}".format(user_name))
print("Thanks for shopping {}".format(user_name))
print("Sorry, we're out of tickets")
5 Answers
KRIS NIKOLAISEN
54,971 Pointslower
needs to be followed by parentheses here:
if proceed_ans.lower() == "y":
Also I am assuming you are indenting properly. I can't tell based on how your post is formatted.
Nick Evershed
6,429 PointsTry type this instead
While tickets_remaining:
Tinotenda Emmanuel Nyamukapa
5,127 PointsI am also facing a similar challenge
Dom Ss
4,339 PointsHere is mine Workspace: https://w.trhou.se/doz1vwq3eh
What I fail to understand is the global scope to local scope. How do I update the variable remaining_tickets. I was thinking that I should just return from my function remaining_tickets, but that did not work.
Carlos Alvarez
2,205 Pointswhen you are subtracting the tickets remaining comes before the number of tickets. EX tickets_remaining -= num_tickets
Cory Mizer
445 PointsCory Mizer
445 PointsThank you!