0

What am I typing wrong? I get the following error:

[RUN OUTPUT]

    Please pick the number next
    to your mood:
    1) Happy
    2) Indifferent
    3) Sad
1,2, or 3?
2
:-|
would you like to choose again? y\n :
y
Traceback (most recent call last):
  File ".\scratch.py", line 35, in <module>
    main()
  File ".\scratch.py", line 5, in main
    again()
  File ".\scratch.py", line 8, in again
    yn = input('would you like to choose again? y\\n :\n')
  File "<string>", line 1, in <module>
NameError: name 'y' is not defined

[/RUN OUTPUT]

[CODE]

    #!/usr/bin/python

def main():
    select()
    again()

def again():
    yn = input ('would you like to choose again? y\\n :\n')
    if yn == 'y':
        select()
    elif yn  == 'n':
        print('bye')
        quit()
    else:
        print('your selection doesn''t make sense, good by')
        quit()

def select():
    print(""" Please pick the number next
    to your mood:
    1) Happy
    2) Indifferent
    3) Sad""")
    choice = input ('1,2, or 3?\n')
    if choice == 1:
        print(':-)')
    elif choice == 2:
        print(':-|')
    elif choice == 3:
        print(':-(')
    else:
        print("you must be drunk")

if __name__=='__main__':
    main()

[/code]

Cœur
  • 37,241
  • 25
  • 195
  • 267
gabe31415
  • 1
  • 2

1 Answers1

0

try using

raw_input('would you like to choose again? y\\n :\n')

instead of

input ('would you like to choose again? y\\n :\n')
mildog8
  • 2,030
  • 2
  • 22
  • 36