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 (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
231,275 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