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

Yusuf Cattaneo
Yusuf Cattaneo
522 Points

What am I doing wrong?

???

breaks.py
def loopy(items):
    # Code goes here
for items in loopy:
    print(items)
Bruno Correia
Bruno Correia
3,114 Points

Hi Yusuf,

There a few issues. First, remember indentation is important. As the code is at the moment, the for loop is not part of the loopy function you are building. Secondly, "loopy" is just the name of the function, not the iterable variable you want to loop. That would be the variable "items" that is passed as an argument (inside parenthesis) of the function. Give this a try and do let me know if there's still something you are not quite sure about:

def loopy(items):
    # Code goes here
    for item in items:
        print(item)

2 Answers

Steven Parker
Steven Parker
229,771 Points

Be careful with indentation.

Anything that is part of a function must be indented. As soon as you start another line on the left edge, Python thinks the function is complete.

That "# Code goes here" comment line is a hint about how far to indent. I'll bet you can get it now without an explicit spoiler.

Yusuf Cattaneo
Yusuf Cattaneo
522 Points

Steven and Bruno Thanks for the explanation!