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 trialAiden Colley
926 PointsNot sure why I keep getting it wrong...
Hello, my code challenge wants me to beak the loop when it hits 'stop' but I checked my code and I didn't see anything wrong.
def loopy(items):
# Code goes here
for item in items:
print(items)
if item == 'STOP':
break
4 Answers
Ben Reynolds
35,170 Points- Check if the item equals 'STOP' before the print statement. If it does, it should hit the break statement before attempting to print.
- In the print statement, print the current item instead of the whole list (item vs items)
Ben Reynolds
35,170 PointsCan you share the latest version of your code?
Ben Reynolds
35,170 PointsA link to the exercise will only show me the default starter code, not the code you've written. Here's the format to go for:
def loopy(items):
for item in items:
# if item text is 'STOP'
break
# print current item (this line will only be reached if break wasn't hit, so no need for an else block)
Aiden Colley
926 PointsThanks! I figured it out:)
Aiden Colley
926 PointsAiden Colley
926 Pointssorry for not replying sooner, I tried what you did but it didn't seem to work.