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 trial

Python

Mazharul Uddin
seal-mask
.a{fill-rule:evenodd;}techdegree
Mazharul Uddin
Data Analysis Techdegree Student 408 Points

indent issues

when i run this code, i keep getting the tickets are sold message after i input a valid integer e.g: There are 100 tickets remaining
What is your name? maz
Hey maz
How many tickets would you like? 50
the total price of tickets is £500
Do you want to proceed. Y/N? y
Sold!
tickets are sold out
There are 50 tickets remaining
What is your name?

code below

TICKET_PRICE = 10

tickets_remaining = 100  

while tickets_remaining >= 1:
    print("There are {} tickets remaining".format(tickets_remaining))
    name = input("What is your name?   ")
    print("Hey", name)
    number_of_tickets = input("How many tickets would you like?   ")
    try:
        number_of_tickets = int(number_of_tickets)
    except ValueError:
        print("there was an error, try again")
    else:
        amount_due = number_of_tickets * TICKET_PRICE
        print("the total price of tickets is £{}".format(amount_due))
        proceed = input("Do you want to proceed. Y/N?    ")
        if proceed.lower() == 'y':
            print("Sold!")
            tickets_remaining -= number_of_tickets
        else:
            print("Thank you, come back next time {}".format(name))
print("tickets are sold out")