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

After giving answer no or n still printing me out : " SOLD!" . What's wrong ?

I've just started that task but i have already stuck. I've used IF , ELIF correct but doesnt matter what i will write it is always giving me answer " SOLD!".

TICKET_PRICE = 10

tickets_remaining = 100  

name = input("What is your name?  ")

# Output how many tickets are remaining using the tickets_remaining variable

print('{} tickets are remaining '.format(tickets_remaining))

# Gather the user's name and assign it to new variable

# Prompt the user by name and ask how many tickets they would like

order = input(" Hi {}!. How many tickets would you like?  ".format(name))
order = int(order)

# Calculate the price

price = order * TICKET_PRICE

print(" Total price is ${} .".format(price))

# Prompt user if they want to proceed
confirmation = input("Are you sure You want to confirm purchase? (Yes/No)   ").lower

# print out to the screen "SOLD!" to confirm purhcase

  # and then decrement the tickets remaining by the number of tickets purchased

if confirmation == "y" or "yes":
  print("SOLD!")
  tickets_remaining -= order

  # Otherwise....

  #Thank them by name


elif confirmation == "n" or "no":
    print("Thank You {}! ".format(name))


# Otherwise....

  #Thank them by name

1 Answer

Try changing the end of your code for the following:

if confirmation == "yes": print("SOLD!") tickets_remaining -= order

else: print("Thank You {}! ".format(name))

There must be other ways to consider both ‘yes’ and ‘y’ but for the purpose of this exercise this should work