Python Python Basics All Together Now Branch and Loop

Albert Vathapally
Albert Vathapally
567 Points

can 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
MOD
Sean M
Treehouse Moderator 7,327 Points

just use:

var_1 =  input("Would you like to proceed?")
KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 47,493 Points

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