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

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