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 PointsI'm getting a NameError unless my input is typed as a String. Even when I copy & paste the exact same code in video
code :shopping_list = []
print("What should we pick up at the store?") print("Enter 'DONE' to stop adding items.")
while True:
new_item = input("> ")
if new_item == 'DONE':
break
shopping_list.append(new_item)
print("Here's your list:")
for item in shopping_list: print(item)
2 Answers
Ryan S
27,276 PointsHi Ross,
It sounds like you are using Python 2. If so, you will need to use the raw_input()
function instead.
input()
does not work the same in Python 2 as Python 3.
I would recommend using Python 3 while following along in these courses.
Tate Price
Courses Plus Student 9,987 Pointscan you post exactly what the error message says
Ross Thompson
7,706 PointsRoss Thompson
7,706 PointsThanks Ryan, big noob error on my part. I'm using a python 2 interpreter to read python 3 code!
Matthew Newell
3,323 PointsMatthew Newell
3,323 PointsWow thanks!