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

What is the wrong!!!!

My code is seems to work fine , but there is a Bummer says Didn't find the right item printed

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

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

You are very close. There is a typo in the if statement:

def loopy(items):
    for item in items:
            if item == "STOP":  # <-- changed to 'item'
                break
            print(item)

Thank you for responding , but i change it to items and the error message still show up Bummer! Didn't find the right items being printed.

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

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey there,

actually Chris and Ratik already gave you the right answer but just to make sure: Did you really change items to item in the condition of the if? Like so:

            if item == "STOP":

From the code you posted in your comment it seems that it's still items however it has to be item because items is the whole list and not just the current item the loop is iterating over.

Thank you , I do change items to item and it works , thank you for illustration

Ratik Sharma
Ratik Sharma
32,885 Points

There's a typo in your code. You're checking

if items == "STOP":
  ...

but you need to check

if item == "STOP":
  ...

Hope that helps!

Thank you for responding , but i change it to items and the error message still show up Bummer! Didn't find the right items being printed.

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