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

Python lists

In the below list problem when I run the scrip and write the first item e.g. milk on the shopping list it give me the below error. Thoughts? NameError: name 'milk' is not defined

shopping_list = list() print("what should we pick up at the store?") print("Enter 'DONE' to stop adding items")

while True: new_item = input("> ") if new_ietm == 'DONE': break

shopping_list.append(new item) print("Added: List has {} items.".format(len(shopping_list)))

print("Here is your list:")

for item in shopping_list:
print(item)

6 Answers

Hi Roland!

You have a typo in your conditional statement! Try correcting that and seeing if it solves your problem!

-Luke

Not sure what the error is? Could you please assist? The 'continue' keyword in the original script is not needed which is why I removed it. On another note I am using version 2.7. Does that make a difference?

Hi Roland! Did you fix the typo?

It may make a difference yes. You should really be writing in Python 3.4 if you are wanting to follow along closely with the Python course.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

On any Python lower than 3.0, use raw_input() instead of input(). Just one of the many reasons we're using Python 3 instead of 2.

Ah works like a charm. Just updated to the latest version of Python. Thanks to both.

When I check the below code from challenge on shopping lists in the Python interepreter it works fine. However in the workspace it says there is an error. Thoughts?

full_name = "Roland Ferrao" name_list = full_name.split() greeting_list = "Hi, I'm X".split() greeting_list = "Hi, I'm {}".format(name_list[0])

Joey Barter
Joey Barter
1,261 Points

Hi Roland, The challenge wants you to return something that has been constructed from the two lists, not just typed as a string. Almost there. Try;

greeting_list[2] = name_list[0] greeting = " ".join(greeting_list) print(greeting)

Thanks Joey.