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

Sun Min
Sun Min
2,941 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

Hello guys. i wrote code as

def loopy(items): for item in items: if items == "STOP": break print("item")

but it keep saying didn't find the right itmes being printed.

does my code is wrong? or and missing code?

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

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Sun,

Your logic looks good, but notice how you are using quotations in your print() function. The way you have it you will simply print out the string "items" every pass of the loop, rather than the actual item in the list. You will need to remove the quotes.

The other thing is check your if statement. Which variable do you want to evaluate as equal to "STOP" -- "item" or "items"?

Hope this helps. Good luck.