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

Chelsea LeBlanc
Chelsea LeBlanc
2,476 Points

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

I keep getting back that i "didn't find the right item" no matter what I substitute for item in items. I tried the various ways of syntax but I can't seem to get it right, and I keep getting this back.

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

2 Answers

Did you copy-and-paste the code from another's question? :unamused:

It is allowed, but just keep in mind that the best way to learn programming isn't to copy-and-paste, but to try to do it on your own. If you are completely stuck, you may copy-and-paste code snippets. Make sure you understand the snippet first, though!

Anyway, to pass the challenge, you must enter this for the first task...

def loopy(items):
    for item in items:
        print(item)

And, once you reach the second task, you can type this:

def loopy(items):
    for item in items:
        if item == "STOP":
            break
        else:
            print(item)
Chelsea LeBlanc
Chelsea LeBlanc
2,476 Points

Well I did, but I did after I found that after checking my work when my own code didn't work. I used copy and paste to see if I had made any indentation errors, but I couldn't spot any.

Thanks for catching that ??