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 Durham
PLUS
Alex Durham
Courses Plus Student 456 Points

break

i hate to have to keep asking questions but i feel like i am really close so can someone tell me what i am missing thanks

breaks.py
def loopy(items):
    for item in items:
        print(item)
        if item == "STOP":
            break
Steven Parker
Steven Parker
231,269 Points

Remember to mark the question closed (by selecting a "best answer") once you are satisfied with an answer.

2 Answers

Hi Alex,

Yes, you're pretty close. All of your code is correct but you have to think about the order of your statements.

What if item is equal to "STOP"? You're going to print "STOP" then you check if it's equal to "STOP" and break out.

The challenge doesn't want you to print "STOP". So you have to check for that first and break out. Otherwise, you can print the item.

Alex Durham
PLUS
Alex Durham
Courses Plus Student 456 Points

Thanks for the response but im still not sure what to do are you saying i have some stuff out of order? Thanks

Yes, you have to do your if check first and then the print. You have to swap the if block and the print statement.