Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRoss Thompson
7,706 PointsNo matter what i type in past the "> ", I get NameError - 'word' is not defined.
CODE: print("This is your shopping list.") print("Please enter one item at a time and type 'Done' when your list is complete.")
shopping_list = []
while 1 > 0: user_choice = (input("> ") shopping_list.append(user_choice)
ERROR: Traceback (most recent call last): File "ShoppingList.py", line 9, in <module> user_choice = str(input("> ")) File "<string>", line 1, in <module> NameError: name 'cake' is not defined
2 Answers
Tate Price
Courses Plus Student 9,987 PointsAre you using python 2, or python 3?
Ross Thompson
7,706 PointsI'm writing python 3 but I'm starting to think my interpreter wants to read python 2?
Tate Price
Courses Plus Student 9,987 Pointstry changing user_choice = (input("> ") remove the extra ( and make it
user_choice = input("> ")
Steven Parker
231,275 PointsSteven Parker
231,275 PointsThe error message and code shown don't seem to match. Be sure you're showing the right code.
Also, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area.
Or watch this video on code formatting.