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 trialAlbert Vathapally
575 Pointscan someone tell me whats wrong with my code?
when i run this in the console, i keep getting the letter y under the question "would you like to proceed", i answer the question with y but im not sure why i get this letter below my code. *(below is my code)
price = 10
tickets_remaining = 100
print("There are {} tickets remaining.".format(tickets_remaining)) name = input("What is your name? ")
print("Hi {},".format(name)) number_tickets = int(input("How many tickets would you like? "))
cost = int(number_tickets * price) print("This is the cost of the tickets,",cost)
var_1 = print(input("Would you like to proceed?"))
if var_1 == "y": print("Sold tickets!!") tickets_remaining -= number_tickets
else: print("Thank you! {}".format(name))
2 Answers
Sean M
7,344 Pointsjust use:
var_1 = input("Would you like to proceed?")
KRIS NIKOLAISEN
54,971 PointsWhat you are seeing is due to this line
var_1 = print(input("Would you like to proceed?"))
Because you are using both input and print, whatever the user enters is then displayed to the screen. The print function returns None which is assigned to var_1. Since this will never equal 'y' the else statement always executes. So eliminate the print function.