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

challange task 2 of 2

what am i missing?

breaks.py
def loopy(items):
    for loopy in items:
        if items == "STOP":
            break
        else:
            print(items)

1 Answer

Ben Slivinn
Ben Slivinn
10,156 Points

Check your 'for' loop, For me the easiest way to remember how to do them right is by saying: "for EACH_ITEM in(side) THE_CONTAINER_OF_ITEMS:

Your loop should look like this:

for loopy in items
      if loopy == "STOP": // Each item called loopy in your code, not items.
         break

Better naming will make you life much easier: (for example)

def loopy(list_of_stuff):
    for items in list_of_stuff:
        if items == "STOP":
            break
        else:
            print(items)