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

michael nomura
michael nomura
2,623 Points

My program does what this question is asking but still says I am wrong

My program does what this question ask but still says I am wrong

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

1 Answer

Hi Michael,

Your code is going to print "STOP" but the challenge only wants you to print the items.

If you reverse the if and print statements then it won't print "STOP" because it will break before reaching the print statement.

Make sure when you reverse them that the print is not indented to the same level as the break. Otherwise, it becomes part of the if and it's unreachable.