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

i cant find what im missing

i cant seem to get it

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

2 Answers

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

You did not put in a condition to go with your for statement:

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

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Cindy is correct, but I would argue that the else statement isn't needed. Here's how I did it:

def loopy(items):
    # Code goes here
    for item in items:
        if item == "STOP":
            break
        print(item)

Our function is accepting an iterable named items. So for every item in that iterable we take a look at it. If the item is equal to STOP then break which will cause it to skip over the print line. Then otherwise we print the item. Hope this helps :sparkles: