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

Alex Deltomme
Alex Deltomme
1,628 Points

What am I doing wrong?

So for some reason, i get "Bummer! Try again!". It seems to me that my code is correct, so what's the problem?

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

2 Answers

Vladimir Vasconcelos
PLUS
Vladimir Vasconcelos
Courses Plus Student 6,433 Points

I think you are trying to use the code of the second part of the challenge first.

Try in the first part only this:

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

After that, use the STOP conditional as required:

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

Peace

Ezra Siton
Ezra Siton
12,644 Points

indentation error. You have one extra space before "break" that's it :) (use tabs)

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



list = ['apples', 'pears', 'STOP', 'peaches', 'beer']

loopy(list)

https://teamtreehouse.com/community/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

Alex Deltomme
Alex Deltomme
1,628 Points

i used the exact same code and it still gives me "Bummer! Didn't find the right items being printed." :(