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.

STEVEN PENA
STEVEN PENA
13,778 Points

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
PRO
Anush Poudel
Pro 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,775 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)
Tilak Muruduru Divakar
Tilak Muruduru Divakar
3,624 Points

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