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

Guy Shafer
Guy Shafer
650 Points

Python Basic Coding Challenge

def loopy(items): for thing in items: print(thing) if thing == "STOP": break loopy(["Louie", "Chewie", "STOP", 1955])

breaks.py
def loopy(items):
    for thing in items:
        print(thing)
        if thing == "STOP":
            break
loopy(["Louie", "Chewie", "STOP", 1955])

1 Answer

Hi there,

You're close - first, the "if" block needs to be moved above the "print" line - that way, if the entry is STOP, it won't print it because it will break before it gets there. I think you've got it right otherwise.

Hope this helps!