Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Shopping List App Second Shopping List App

Second Shopping List, when i type in apples pears and DONE, DONE gets included in my Here's your list??

make a list to hold onto our items

shopping_list = []

print out instructions on how to use the app

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

while True: # ask for new items and store answer into a variable new_item = input("> ")

# now add the new items(new_item) above and add to our variable shopping_list
shopping_list.append(new_item)

#we need our user to be able to quit the app
if new_item == 'DONE':
    break

be able to quit the app

print out the list

print("Here's your list:")

for item in shopping_list: print(item)

3 Answers

Steven Parker
Steven Parker
216,012 Points

:point_right: Your issue is caused by the order of execution.

If you don't want "DONE" to be added to the list, you need to move the test for "DONE" (along with the break it does when true) BEFORE the place where you append the new item to the shopping list.

Thankyou for your response, I appreciate it very much, I will try this.

That worked perfectly Steve, again, thankyou very much, Chris