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 python

Hi community!. I have a problem in my code and I do not what happen!!, Could anybody help me? , The indentation is correct and the quotes too.

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

2 Answers

Hi Lizeth,

Your code is working fine on the second task. You have to write the code that will pass the first task and then write the code you have just written. You must do exactly what the challenge asks you for :)

You only need to write this for task 1:

def loopy(items):
    for item in items:
        print(item)

After you pass that task, you write what you have just written:

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

I hope this helps. ~Alex

Thank you everyone for your help :) , it works well

Ash Singh
Ash Singh
12,548 Points

I checked it on my IDE and it works for "STOP" that is it breaks out of the item array but does not work for "Stop". Python is case sensitive

Actually, the challenge is ONLY expecting you to break if the item is uppercase "STOP".

Therefore, changing case doesn't matter for this situation.