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 Shopping List Introduction

Hello. When iterating through my for loop, I would like to not print out the the DONE option.

I have tried continue, to remove the done option in my printed list... Please advise.

am having the same problem

make a list to hold our items

todo_list = []

# out instructions on how to use the app
print("the thing i have to do")
print("Enter 'DONE' to stop the app")

while True:
     # ask for new items
    new_item = input("> ")

    # be able to quit the app
    if new_item == 'DONE':
        break

# add new item to our list
todo_list.append(new_item)

# print out the list
print("Here's your list")

for item in todo_list:
  print(item)

3 Answers

Anush Poudel
PLUS
Anush Poudel
Courses Plus Student 551 Points

Print out the list items after you've iterated through the loop. Or maybe check the item if it is "DONE" and break the loop before you're printing things. It would be nice if you'd show your code for more detailed explanation.

Youssef Moustahib
Youssef Moustahib
7,779 Points

Hi,

Firstly, you need to indent this properly as you have only given it two spaces:

for item in todo_list: print(item)

Secondly, you need to indent the append part of the code into the while loop, so it should be:

while True: # ask for new items new_item = input("> ")

# be able to quit the app
if new_item == 'DONE':
    break

# add new item to our list
todo_list.append(new_item)

Just don't add 'DONE' to your shopping list. While printing iterate through the list.