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 trialMoatazBellah Ghobashy
Python Web Development Techdegree Student 2,940 PointsWhat is the wrong!!!!
My code is seems to work fine , but there is a Bummer says Didn't find the right item printed
def loopy(items):
for item in items:
if items == "STOP":
break
print(item)
3 Answers
Chris Freeman
Treehouse Moderator 68,454 PointsYou are very close. There is a typo in the if
statement:
def loopy(items):
for item in items:
if item == "STOP": # <-- changed to 'item'
break
print(item)
Tobias Helmrich
31,603 PointsHey there,
actually Chris and Ratik already gave you the right answer but just to make sure: Did you really change items to item in the condition of the if? Like so:
if item == "STOP":
From the code you posted in your comment it seems that it's still items however it has to be item because items is the whole list and not just the current item the loop is iterating over.
MoatazBellah Ghobashy
Python Web Development Techdegree Student 2,940 PointsThank you , I do change items to item and it works , thank you for illustration
Ratik Sharma
32,885 PointsThere's a typo in your code. You're checking
if items == "STOP":
...
but you need to check
if item == "STOP":
...
Hope that helps!
MoatazBellah Ghobashy
Python Web Development Techdegree Student 2,940 PointsThank you for responding , but i change it to items and the error message still show up Bummer! Didn't find the right items being printed.
def loopy(items):
for item in items:
if items == "STOP":
break
print(item)
MoatazBellah Ghobashy
Python Web Development Techdegree Student 2,940 PointsMoatazBellah Ghobashy
Python Web Development Techdegree Student 2,940 PointsThank you for responding , but i change it to items and the error message still show up Bummer! Didn't find the right items being printed.
def loopy(items): for item in items: if items == "STOP":
break print(item)