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

breaks.py

I do not understand why the code is not working...

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

3 Answers

Cole Wilson
Cole Wilson
7,413 Points

I think the function name loopy and iteratable variable loopy are getting confused.

Try replacing line 2 with:

for thing in items:

Then replace your usage of items in the print and if with thing.

Cole Wilson
Cole Wilson
7,413 Points

This is what I was trying to say. I believe this should work. I'm on my mobile and can't test easily.

def loopy(items):
    for thing in items:
        print(thing)
        if thing == 'STOP':
            break
Cole Wilson
Cole Wilson
7,413 Points

Was able to test using Python 3.3

yea from trial and error after what you said i got it to work, simple mistakes

Cole Wilson
Cole Wilson
7,413 Points

Nice! Best way to learn.