-1

python 2.7.9 so i wanted to make a script to run constantly where i can take notes on names and characteristics but i don't know why its throwing this error. eventually i would like it to be exported to a file so it can save the inputted information.

Traceback (most recent call last): File "C:\Users\Admin\Desktop\PythonFiles\Dictionary.py", line 18, in key = input("Enter a player name: ")

File "", line 1, in Name Error: name 'bob' is not defined

basket = {}
print("""
Note Program:
___________
1: Add Item
2: Remove Item
3: View
0: Exit Program

""")

option = int(input("Enter an Option: "))

while option != 0:
if option == 1:
    key = input("Enter a player name: ")

    if key in basket:
        print("Name Found!...")
        value = input("adding notes: ")
        basket[key] += value

    else:
        value = input("Notes: ")
        basket[key] = value

elif option == 2:
    key = input("Enter a player name: ")
    del(basket[key])

elif option == 3:
    for key in basket:
        print(key,":",basket[key])

elif option !=0:
    print("please enter a valid option")

option = str(input("\n\nEnter an option: "))

else:
    print("Note Program Closed.")
Stopit Donk
  • 33
  • 1
  • 4

1 Answers1

1

You should use raw_input() instead of input(), as input is trying to eval() which is causing the exception.

  • raw_input() takes the input and passes it back as a string.
  • input() will actually run as eval(raw_input()).
Eytan Avisror
  • 2,860
  • 19
  • 26