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

Help with break Pls.

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

I cant pass with this code, why?

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

4 Answers

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

Hi Levi! You're pretty close here so I'm going to give a couple of hints. I feel like this will be a better overall learning experience for you instead of just giving the answer.

  • Currently, if I send in "STOP", your code will first print out "STOP" then check to see if it was "STOP"
  • Your indentation is a bit off
  • Check first to see if the item is "STOP"
  • If the item is "STOP" break
  • Otherwise print the item

Good luck, but let me know if you're still stuck! :sparkles:

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

You are certainly entitled to your opinion. However, I'd point out that the challenge you linked to had a different set of difficulties as they were failing on step 1... not step 2. I, much like yourself, am doing my best to help out fellow students.

Brian Jensen
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

Jennifer Nordell Hehe I was completely just being silly :stuck_out_tongue_winking_eye: since you have twice VERY eloquently answered this challenges questions tasks :smiley:

Oh and to play with the emoticons more that you taught me lol. :grin:

Brian Jensen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

Jennifer Nordell I just want to make sure that you know that the answer I was referring to in the link I posted here was also from you. The joke I failed to make was that it was you vs you. I did not mean any offense at all, I absolutely LOVE the answers you gave here and there for task 1 and task 2. I hope to one day help other students in such a detailed and beautifully written way as you do. I have a lonnnggg way to go.

Thanks for the answers! :)