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 trialSpencer Heflin
7,389 PointsPart 2 of Shopping List Code Challenge
I'm not sure what I'm doing wrong on this part. I feel like I'm missing something obvious, but I can't figure out why the break isn't working. Any help would be greatly appreciated.
def loopy(items):
print(items)
if items == 'STOP':
break
Greg Kaleka
39,021 PointsHey Spencer,
For future reference, you can edit your posts and answers and comments by clicking on the three-dots icon below your post, and choosing edit. I took the liberty of changing it for you, which I can do because I'm a moderator.
1 Answer
Greg Kaleka
39,021 PointsHi Spencer,
Normally I wouldn't just give an answer, but you've pretty much got it solved. Your indentation is a little wonky, and your for loop is gone! You obviously had it in there for Challenge Part 1, so I'm gonna just put it back in there. Let's also make sure we break before printing the item if the item is "STOP" (I'm not sure it's required, but seems like the right thing to do):
def loopy(items):
for item in items:
if item == 'STOP':
break
print(item)
Let me know if anything doesn't make sense. Also - DON'T COPY AND PASTE! Typing it out is helpful
Cheers
-Greg
Spencer Heflin
7,389 PointsAwesome thanks for your help.
Spencer Heflin
7,389 PointsSpencer Heflin
7,389 Pointssorry new_item should actually be items. I was trying a bunch of different things and forgot to change it back.