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

Loopy Function

Challenge Task 1 of 2

I need you to help me finish my loopy function. Inside of the function, I need a for loop that prints each thing in items.

Reminder: Check your syntax and indenting! –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– What I'm doing doesn't seem to be working. Help me please. ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

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

1 Answer

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

Hi there! You are currently working on Step 1 of the challenge. Step one says nothing of including a break statement or checking if the item is equal to "STOP". The only requirement of this step of the challenge is to loop through the items list and print out each item.

The break statement and the check for "STOP" will be required at Step 2. But if you do them at Step 1, it will cause the challenge to fail The reason for this is because Treehouse is sending in a list (presumably with the word "STOP" in it). The code in Step 1 should print out "STOP", but not the code in Step 2. Thus, the Bummer message is correct. You are not printing out the correct items.

Try the challenge again making sure the code matches the requirements for that particular step.

Good luck and happy coding! :sparkles:

Thank you so much! I understand how to do it now and where I went wrong.