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