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

I am super lost with the breaks.py challenge

I can do the first part of this just fine but I have tried several different ways to do the second part where you add the break code and I cannot get it to work. I am very new to coding so I am likely just not doing something simple. If I can at least get a hint that would be great.

3 Answers

Reyam Marcos
PLUS
Reyam Marcos
Courses Plus Student 10,367 Points

you can review this one, an if statement inside a for loop :)

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

hope it works

def loopy(items):
    for i in items:
        if i is "STOP":
            break;
        print (i);

I can see where its going wrong for you. '==' is equality testing whereas 'is' is identity testing. In question they had mentioned, 'STOP' is a string.

Thanks everyone. I knew I was just something simple I was doing wrong lol.

Delighted to help. Please accept the answer you find fit and correct... for it closes the question in the community. Thank you.