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

Austin Jimison
Austin Jimison
3,849 Points

what's wrong with my loop, and break statement?

is my indentation incorrect?

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

2 Answers

Phillip Kerman
PLUS
Phillip Kerman
Courses Plus Student 285 Points

Works for me, but I think you're SUPPOSED to have indentations in multiples of 4:

def loopy(items):
    for item in items:
        print (item)
        if item == "STOP":
            break
Hassaan Ahmad
Hassaan Ahmad
1,979 Points

Hey Phillip, it's not necessary to keep the indentations in multiples of four. It's just a common practice. You just have to keep the same indentation for a code block.

Hassaan Ahmad
Hassaan Ahmad
1,979 Points

Hey, your indentation is fine. The problem is that you are calling to print the items in your code instead of item