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

Please what am i doing wrong in this code?

Oops, I forgot that I need to break out of the loop when the current item is the string "STOP". Help me add that code!

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

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! Oh wow you're really close on this one. You're comparing (or trying to) the entire list to "STOP" instead of the item in your list. You've chosen to name the individual items as i. So if I just minorly correct one line, your code passes:

if i == "STOP":

The list is named items, but it's going to go through that list and check each individual named i. If the individual item is "STOP", then break. Otherwise, we print the item or i. And the print part you got entirely correct!

Hope this helps! :sparkles:

oh, oh, oh.... silly me, never thought of that. Thanks a lot @ Jennifer...