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