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

LeVar Carter
LeVar Carter
10,771 Points

Need help with loopy function...

cant figure out what i'm doing wrong

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

    for loopy in items:
        if  items == "STOP":
            break

        else:
            print(items)

2 Answers

The problem is you are testing if the entire array = "STOP" instead of the index inside the for loop and then printing the whole array instead of the selected index, it should look like this

def loopy(items):
    # Code goes here

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

You had just got the variable/array names mixed up

LeVar Carter
LeVar Carter
10,771 Points

Thanks for the help! I appreciate it.