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 Continue

shopping list

# make a list to hold on to ur items
shopping_list = []

# print out instructions how to use the app
print("what should we pick up at the shop?")
print("Enter 'DONE' to stop adding items.")

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

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

# add new items to our list
shopping_list.append(new_item )

# print out the list
print("here's your list: ")

for item in shopping_list:
    print(item)

i want my code to print out the list of items but it is refusing

Hi MUZ140259 Juliana Kofi, I've formatted your code to use code blocks. Please refer to the Markdown Cheatsheet (linked under the text box for entering your question/answer/comments) for instructions on how to format code blocks.

1 Answer

Steven Parker
Steven Parker
216,121 Points

Your code looks good, but I can't check your indentation since you didn't blockquote your code. So compare yours to this copy which is blockquoted. Look carefully at the indentation.

shopping_list.py
# 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
    new_item = input("> ")

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

    # add new items to our list
    shopping_list.append(new_item)

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

for item in shopping_list:
    print(item)

If it's not a spacing error, are you sure you entered DONE at the end (in all caps) to get it to print? As, is, the test is case-sensitive.

I've formatted Juliana's code, and you're correct, it was an indentation error on the line for appending items.