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

loops

I need you to help me finish my loopy function. Inside of the function, I need a for loop that prints each thing in items.

breaks.py
def loopy(items):
    # Code goes here
for items in loopy:
    print(loopy)

2 Answers

Marek Zakrzewski
Marek Zakrzewski
2,920 Points

Hi Jeffrey,

The issue in your code is that you're trying to iterate through the function itself, not the iterable passed as an argument. You also miss indentation within your function.

Use the loop, to iterate through the data you input into the function - items.

Hope that helps. If you need more help, please reply and I will try to answer in more detail.

Happy coding!

Marek

As Marek stated earlier you are using the function name the iterative item, also the for loop is not using its proper variable. It should look something like this:

[Moderator redacted]

Items in the for loop is the variable that is being iterated. Each element of that variable is put into item, and then printed. then the next element in items will be placed into item. This will run until it reaches the end the the items

Michael Hulet
Michael Hulet
47,912 Points

Hey William! For future reference, it's frowned upon in the community to post code that can be copied and pasted and just work, especially if it passes a Treehouse challenge. If you're going to post code, be sure to provide a thorough explanation about how your code works and why it's the right code for the job. I've redacted the code in your answer accordingly. If you'd like, feel free to post a modified version of your code again that doesn't pass the challenge with a copy/paste. Great job explaining it in your answer, though! Happy coding!