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

Sean McCormick
Sean McCormick
1,206 Points

Can't break the loop Python Basics course challenge task 2 of 2

hello,

        I'm having trouble with code challenge 2 of 2. My code works fine in notepad ++ or at least as far as I know i.e. when it finds "STOP" in items it prints STOP and stops.  However I cant seem to get it to work properly here. Any assistance would be appreciated 

Thank you Take Care, Sean

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

3 Answers

Right code, wrong order, we don't want to print out the word "STOP".

def loopy(items):
    for s in items:
        if s == 'STOP':
            break

        print(s)
Sean McCormick
Sean McCormick
1,206 Points

Awesome thanks ... I'm a bonehead

I tried your code, and page is not accepting it

def loopy(items):
    for s in items:
        if s == 'STOP':
            break

        print(s)

it's not accepting mine either. my Python IDE is not showing any errors and I'm wondering why the page is not accepting the code.

my code

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