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 trialKarl Long
1,661 Pointsbreak in a printing loop for Stop
what am I doing wrong here? Thank you
def loopy(items):
for item in items:
if item in items == "STOP":
break
else:
print(item)
1 Answer
Jennifer Nordell
Treehouse TeacherHi, Karl! Oh wow, you're really close here. Your for loop says for item in items
and that's entirely correct. It's your if
statement that's a little off. That for loop is going through the entire list of items. And every one it pulls out is assigned to a temporary variable named item
. So only item
needs to be checked to see if it's equal to "STOP". Long story short: remove in items
from your if
statement, and your code passes!
Hope this helps!