0

I get the error message "NameError: name 'wine' is not defined" whenever I run the following code:

def pub():
 print ("Welcome to the pub; what will you be drinking tonight?")
 answer = input("Choose the type of beverage you desire")
 if answer == " Beer" or answer == " beer":
    print ("You've come to the right place; have a seat!")
 elif answer == " Wine" or answer == " wine":
    print ("Sorry, we don't serve wine here. Why don't you try next door?")
 elif answer == " Cocktails" or answer == " cocktails" : 
    print ("Cocktails? who drinks those anymore?")
 elif answer == " Liquor" or answer == " liquor":
    print ("Sorry, we don't serve hard drinks here.")
 else:
    print ("You didn't pick a legitimate drink; try again!") 
pub()
def beer_selection():
   print ("Now we need to know what types of beers you're into. Select one of      the \
following flavor profiles:")
flavor_profiles = ["Rich and malty", "Crisp and hoppy", "Light and fruity",    "Smooth and balanced", "Piney and hoppy"]

Any help would be greatly appreciated!

3 Answers3

1

Try:

raw_input()

instead of:

input()
Asking Questions
  • 637
  • 6
  • 18
1

The issue is that your input is being evaluated. This is the behavior of input() in Python 2.x. Since you have no variable named wine, an exception is thrown. You can check this behavior by typing " Wine" (with the double quotes), which works fine because it is now being entered as a string rather than a variable name.

You can use raw_input() instead, which will work with your value Wine, ie:

answer = raw_input("Choose the type of beverage you desire")
grovesNL
  • 6,016
  • 2
  • 20
  • 32
0

You might be using python 2.7

for python 2.7 the 'input' is 'raw_input'

replace input function with this

 answer = raw_input("Choose the type of beverage you desire:")
  • 1
    Okay; that was the issue. I was using python 3.5 in the lab and forgotten that I had an older version installed on my computer at home. Thanks for the help everyone! – durkadork Apr 05 '15 at 22:21