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 trialRegina Ackah
2,649 Pointsmy code does NOT subtract
please help me solve the issue with my code. tickets_remaining does not subtract after I can't seem to find the problem at all.
while tickets_remaining >=1 : print("We have {} tickets remaining".format(tickets_remaining)) name = input("What is your name? ") num_tickets = int((input("How many tickets do you need {} ".format(name)))) user_price = num_tickets * TICKET_PRICE print("Total due is ${}".format(user_price)) proceed = input("do you want to continue? Y/N ") if proceed.lower() == "Y": print("sold") tickets_remaining = tickets_remaining - num_tickets else: print("Thank you {}".format(name)) print("Sorry the tickets are sold out ")
1 Answer
AJ Tran
Treehouse TeacherHi Regina Ackah! I found a little bug in your conditional :)
if proceed.lower() == "Y":
tickets_remaining = tickets_remaining - num_tickets
proceed.lower()
is never going to be equal to "Y"
! Because the code will always compare a lowercase letter to a capital letter. It will always return False, so your next line of subtracting code will never run.
So the easiest fix would be to change your conditional to compare against a lowercase "y"
.
It happens to everyone! One character will ruin the whole program with a bug and sometimes you just need another person to read the code :)
Regina Ackah
2,649 Pointsoooh Thanks soo much, i have been on this for hours.
AJ Tran
Treehouse TeacherAJ Tran
Treehouse TeacherYou can wrap your code in triple backticks to format it neatly. When you open the text editor to make a post or comment, there is a link that says
And there is an example in there.