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 trialalekseibingham
4,491 PointsCant figure out whats wrong with my break code
I keep reading that the indentation is wrong but im not seeing it, any explanation would be wonderful and much appreciated!
def loopy(items):
for i in items:
print(i)
if i == "STOP":
break
3 Answers
Jon Mirow
9,864 PointsHi there!
Your if block is outside your else block, just indent the if block to line up with the code inside the for loop (the print statement)
Hope it helps!
alekseibingham
4,491 Pointsyea i cant figure it out for the life of me and im looking all around and people having the same issue :P
alekseibingham
4,491 PointsFINALLY, i forgot the freaking ":" at the end of my if statement that checks for the string "STOP"
alekseibingham
4,491 Pointsalekseibingham
4,491 Pointswell i indented and i got an error back saying "didnt find the right items being printed"
Jon Mirow
9,864 PointsJon Mirow
9,864 PointsI suspect it's because at the moment your code prints out "STOP" then checks if it's there?