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

Debasis Nath
Debasis Nath
3,316 Points

again what is wrong in this code?

it"s showing bummer.

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

1 Answer

Stuart Wright
Stuart Wright
41,102 Points

There are a couple of things to fix here:

1 - 'items' is the entire list, and 'item' is the current element in list. It is 'item' that you should be checking in your if statement, not 'items'. Same for the print statement - you should only be printing 'item'.

2 - The challenge does not want you to print the 'STOP' item, so the if condition with break statement should come before the print statement, and only if the item is not 'STOP' should it be printed. Also, be careful with your indentation - anything inside an if block should be indented, which you have not done correctly with your break statement in the current code.