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 trialMichael Dinnall
6,730 Pointswhy isnt my function working ? Needed: a break to exit the loop
def loopy(items):
for item in items:
if item == 'STOP':
break
return item
def loopy(items):
for item in items:
if item == 'STOP':
break
2 Answers
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 PointsHi Michael! I see that you have returned the item if it's not a break? I think the challenge wants you to print the item like this:
def loopy(items):
# Code goes here
for item in items:
if item == "STOP":
break
print(item)
Hope that helps! Let me know if you have any questions! :)
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 PointsAh ok - I'm pleased you found the issue! :)
Michael Dinnall
6,730 PointsMichael Dinnall
6,730 PointsHi Alexandra its still given me "Bummer! Didn't find the right items being printed." I also tried:
I still got the same result
Michael Dinnall
6,730 PointsMichael Dinnall
6,730 PointsActually, I just solved it. I was printing (item) not (items). Thanks for your suggestion it made me look into it a little more !