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

kyle gonzalez
kyle gonzalez
3,965 Points

Helps with breaks.py Objective 2: Adding a "break" code block

I'm unsure how to proceed with this problem. If someone could explain how to add a code block that exits i.e. breaks out of a function.. that would be helpful. He also asks for us to add a for loop to a function which is quite confusing to me. If someone could walk me through the logic of this code challenge I would greatly appreciate it!

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

1 Answer

David Mobley
David Mobley
2,609 Points

Hello :) your 'if/else' statement needs to be nested under your for loop.