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

Eddie Black
Eddie Black
1,670 Points

Didn't find the right items being printed

I'm receiving the above error message, any help will be appreciated

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

1 Answer

Idan Melamed
Idan Melamed
16,285 Points

Hi Eddie, you are pretty close!

A few things I can remark on:

  1. The variable items is a list. The variable things only store one thing from item at a time. So you might want to change 'things' to 'thing' (or better yet: 'item'). It won't effect your code, but it will make it more readable to other programmers.
  2. You need to indent the last line back, so it start from the same position as the if statement.
  3. You want to print things (or, again, item).

The end result should look something like this:

def loopy(items):
    # Code goes here
    for item in items:
        if item == 'STOP':
            break
        print(item)
Eddie Black
Eddie Black
1,670 Points

Thank you, #2 was the issue and also changing the variable to item