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

Python

Kareem Saleh
Kareem Saleh
225 Points

My python code works perfectly on workspace but not on my mac when i tried to run it through the console, any ideas?

It gives me the following error:

What is your first name? Kareem Traceback (most recent call last): File "hello.py", line 1, in <module> first_name = input("What is your first name? \n") File "<string>", line 1, in <module> NameError: name 'Kareem' is not defined

Here's the code:

first_name = input("What is your first name? \n")

print('Hello,',first_name.capitalize())

if first_name.lower() == "kareem": print(first_name.capitalize(),'is learning Python')

elif first_name.lower() == "maximilliane": print(first_name.capitalize(), "is learning with fellow students in the community! Me too!")

else: # This is just in case we have a younger user who can't yet read. age = int(input("How old are you?\n")) if age <=6: print("Wow you're {}! If you are confident with your reading already...".format(age)) print ("You should totally learn Python, {}".format(first_name.capitalize())) print("Have a Great day {}!".format(first_name.capitalize()))

2 Answers

You will have different versions of python running on each machine.