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

Daniel Sayre
Daniel Sayre
884 Points

breaks.py. The break is throwing me for a loop

I have tried quite a few variations on this code but I just don't seem to be getting anything but errors.

breaks.py
def loopy(items):
    # Code goes here
    for item in items:
        if items() !='DONE'
            print(items)
        else:
            break
Daniel Sayre
Daniel Sayre
884 Points

I have also tried: def loopy(items): # Code goes here for item in items: if items() =='DONE': break else: print(items)

def loopy(items): # Code goes here for item in items: if items =='DONE': break else: print(items)

1 Answer

Hey Daniel,

Your code is almost right, you're just missing a few things.

For one, your if statement is missing a ':'

and remember you're iterating over a list called 'items' by 'item'

When you wrote your if statement you're trying to call 'items' like a function.

It should be 'item' since that's what you're iterating by.

lastly you should be printing the individual 'item' not 'items', which is the entire list that was passed into the loopy function.

def loopy(items):
    # Code goes here
    for item in items:
        if item !='DONE':
            print(item)
        else:
            break