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 Python Basics (Retired) Shopping List Shopping List Project

Script doesn't work outside workspace.

Hello.

I tried running the script on my Mac's terminal and I get the following error:

What should we pick up at the store? Enter 'DONE' to stop adding items.

Apples Traceback (most recent call last): File "shopping_list.py", line 7, in <module> new_item = input("> ") File "<string>", line 1, in <module> NameError: name 'Apples' is not defined

However the script runs just fine in workspaces. Am I doing something wrong?

1 Answer

Ricky Catron
Ricky Catron
13,023 Points

I think the mac has python 2 installed. Work spaces uses python 3. If you post your code I can tell you what to change to make it run on python 2. Or you could install python 3 on your mac.

You are correct, python 2 seems to have been the issue. I installed python 3.4.1 and it works great. Thanks for the help Ricky!

Ricky Catron
Ricky Catron
13,023 Points

Of course haha. I use python 2 personally but shh don't tell they will call me old fashioned ;)

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Ha, Ricky Catron! You're busted!

Python 2 is a good, solid version of Python. It's just not going to get better, unlike Python 3. :)

Ricky Catron
Ricky Catron
13,023 Points

There is a ton of truth to that. I am just slowly shifting over. I like my raw_inputs! Although print now being a function makes a ton more sense. I am looking to the future of python in a different way. I would rather Python 2 run on any device then python 3 be expanded so instead of switching to python 3 I have been working with kivy to develop an app.