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 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. :-)