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

Mike Nunyabeez
Mike Nunyabeez
4,677 Points

Items not appending to my list

reminder_list = []
print("What do we need to rememeber?")
print("Enter 'DONE' to stop adding items.")
while True:
    new_item = input("> ")

    if new_item == "DONE":
        break
        reminder_list.append(new_item)

print("Here's your list:")

for item in reminder_list:
    print(item)

When I type 'DONE' nothing is printing in my list.

Jamal Scott
Jamal Scott
9,656 Points

its most likely because the append is in the if statement, try bringing it out

reminder_list = []
print("What do we need to remember?")
print("Enter 'DONE' to stop adding items.")
while True:
    new_item = input("> ")

    if new_item == "DONE":
        break
    reminder_list.append(new_item)

print("Here's your list:")

for item in reminder_list:
    print(item)
Mike Nunyabeez
Mike Nunyabeez
4,677 Points

Thanks. I would upvote your answer but you answered as a comment I believe, instead of an answer. Appreciate the fast response!

2 Answers

Gang Liu
Gang Liu
519 Points

Thank you so much for the Q&A! I have the same issue and got the solution. :-)