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 Break

need help with code

need help with code

breaks.py
def loopy(items):
    # Code goes here
items =[]
While True:
    new_item=input("> ")
    if new_item =='STOP':
       break
    items.append(new_item)
print ("Here is your list:")
for item in items:
    print(loopy)

7 Answers

def loopy(items):
    # Code goes here
    for item in items:
        if item == 'STOP':
            break
        else:
            print(item)

Make sure that your indentions are correct.

If you follow the instructions closely it's hard to miss. It tells you to add a for loop that prints each item but first checks to see if the item is equal to 'STOP' and if it does then break the loop, so

step 1:

for item in items:

step 2:

if item == 'STOP': break

step 3:

else: print(item)

def loopy(items): # Code goes here items=[] while True: new_item=input("> ") items.append(new_item) print ("Here is your list:") for item in items: if item == STOP': break else: print(item)

''' def loopy(items): # Code goes here items=[] while True: new_item=input("> ") items.append(new_item) print ("Here is your list:") for item in items: if item == STOP': break else: print(item) '''

seems it doesnt work

thanks Jeremy

You're welcome :)