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 trial
Temo Vargas
16,319 PointsPython error
I am using Atom text editor and mac's terminal. Everything i try to run this code(#1) i get error (#2)
(#1)
name = input("What's your name?")
if name == "Temo":
print(name + " is a lumberjack")
else:
print(name +" sleeps all day")
(#2)
What's your name?Temo
Traceback (most recent call last):
File "lumberjack.py", line 1, in <module>
name = input("What's your name?")
File "<string>", line 1, in <module>
NameError: name 'Temo' is not defined
[edit formatting - cf]
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsTemo, you didn't mention which version of Python you are using. If you're using Python 2.7, input() expects raw input values. so if you respond Temo (without quote) it will not interpret it as a string. Try using "Temo" (with quotes).
Alternatively, if you switch to Python 3.x, input() treats all input as a string so the quotes are implied.
Temo Vargas
16,319 PointsTemo Vargas
16,319 PointsI'm using python 2.7.10. Thanks for the help, I got it working. Also is there a way to update to the latest version of python?
Gunhoo Yoon
5,027 PointsGunhoo Yoon
5,027 PointsPython3 and Python2 is like two separate branch so you can just download Python3 from official site and use both.