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 Branch and Loop

My tickets remaining stays at 100

Heres my code


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":

tickets_remaining = (tickets_remaining - ticket_amount)
          print("bummer, {}".format(user_name))

print("Thanks for shopping {}".format(user_name))

print("Sorry, we're out of tickets")

5 Answers

lower 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.

Try type this instead

While tickets_remaining:

I am also facing a similar challenge

Dom Ss
Dom Ss
4,339 Points

Here 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
Carlos Alvarez
1,399 Points

when you are subtracting the tickets remaining comes before the number of tickets. EX tickets_remaining -= num_tickets