Python Using Databases in Python Our Diary App Switching It Up

Paul Bentham
Paul Bentham
24,088 Points

Name_Error on Switching it Up? 'a' is not defined... using terminal on Ubuntu.

When I run diary.py in terminal on Ubuntu I get a Name_Error when I type a or v. If I put them inside quotes I don't get the error?

I tried to get around this by putting str() around the input() but that didnt work.

Here is the terminal output:

office@Office-PC:~/Desktop/Database example$ python diary.py 
Enter 'q' to quit.
a Add an entry
v View previous entries
Action: a
Traceback (most recent call last):
  File "diary.py", line 51, in <module>
    menu_loop()
  File "diary.py", line 30, in menu_loop
    choice = str(input('Action: ').lower().strip())
  File "<string>", line 1, in <module>
NameError: name 'a' is not defined
office@Office-PC:~/Desktop/Database example$ 

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Guessing you're on Python 2.7 instead of 3.4 like we use for everything at Treehouse. You'll need to use raw_input() instead of input().