Python Python Basics All Together Now Branch and Loop

Cannot get the response "Sold!" and decrement the tickets remaining

Not sure what went wrong with my code

prompt user if they want to proceed. Y/N?

should_proceed = input("Do you want to proceed? Y/N")

#If they want to proceed 
if should_proceed.lower() == "y":
    #print out to the screen "SOLD!" to confirm purchase
    print("SOLD!") 
            #and then decrement the tickets remaining by the number of tickets purchased
    tickets_remaining -= num_tickets
#Otherwise...
else:
    #Thank they by name
    print("Thank you anyway,{}!".format(name))

1 Answer

John Lack-Wilson
John Lack-Wilson
8,159 Points

Hey Helen, it seems as if this might not be all of your code? If so, could you please post the remainder of it so we can see if there are different issues.

Here are the issues I can see from this snippet:

  • tickets_remaining hasn't been assigned a value before you try to decrement it
  • num_tickets hasn't been assigned a value
  • name hasn't been assigned a value

The above may not be related to the issues you're having but without seeing all of your code it is hard to tell.