Oct-24-2020, 12:57 AM
(This post was last modified: Oct-24-2020, 01:01 AM by cris_ram415.)
I am getting a NameError in my text based rpg and I was wondering if anyone could help. Here's the code:
If there's any way you could help me, I'd really appreciate it! Thanks
def chooseCoffee ():
coffee = ""
while coffee != "iced coffee" and coffee != "black coffee" and coffee != "cappuccino": # input validation
coffee = input("Choose your coffee (iced coffee, black coffee, or cappuccino): ")
return coffee
chooseCoffee()
if(coffee == "iced coffee"):
print('Cashier: "Iced coffee it is!"')Here's the error I get:Error: if(coffee == "iced coffee"):
NameError: name 'coffee' is not definedMy goal is to get the program to print the message "(coffee) it is!"If there's any way you could help me, I'd really appreciate it! Thanks
