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 trialMoises Miguel
5,028 PointsIm using sublime text and when i try to write something in my list i get a error message in my terminal.
It says that what ever i type in is "not defined". How do i solve this?
shopping_list = []
print("What should we pick up at the store ?") print("Enter 'DONE' to stop adding steps ")
while True: new_item = input("> ")
if new_item == "DONE": break
shopping_list.append(new_item)
print("Here is your list: ")
for item in shopping_list: print(item)
1 Answer
Alexander Davison
65,469 Pointstry typing this into the Terminal:
python -v
What result does it print out when you type this?
Moises Miguel
5,028 PointsMoises Miguel
5,028 Pointsa lot of words and than the 3 greater than symbols. so it takes me to the python shell?
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsOh never mind. I thought that would show you the version of Python.
Alexander Davison
65,469 PointsAlexander Davison
65,469 Pointscan you try typing python --version into the shell?
EDIT: And also tell me what you get back?
Moises Miguel
5,028 PointsMoises Miguel
5,028 PointsPython 2.7.10
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsAnd what's the command you use to run your file?
Moises Miguel
5,028 PointsMoises Miguel
5,028 Pointspython shopping_list.py
Alexander Davison
65,469 PointsAlexander Davison
65,469 Pointsaha! You are using Python 2, which sometimes causes errors with your Python 3 code. In Python 2, you cant just type in "Hello!" into an input field. If you do so, Python 2 will start to look for a variable named like that. So, there's a couple ways to fix that. You could use the raw_input() function instead of input(), or, you can install python3 then type in this instead into the Terminal:
python3 shopping_list.py
Hope this helps and good luck coding! ~Alex
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsAlso, you might find this course helpful for these things.
Moises Miguel
5,028 PointsMoises Miguel
5,028 PointsThanks a lot alex, everything is working just fine now!
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsNo problem!