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

The Challenge says try again and i don't know what's wrong with my code

I have written this code in this challenge but the only error i get is try again. can someone please tell me what's wrong with it and why won't it pass?

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

1 Answer

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,076 Points

The reason your code isn't working is because your break is not inside the loop itself, so your code never breaks out of the loop.

Also remove your first line: item = items, think about what you just told that line to do, and then what you think it will do with your code.

Thanks for your response i did that and now it says the right items aren't being printed the code is now like this:

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

I found out what was wrong with it. thanks for the help though