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 trialAlex Durham
Courses Plus Student 456 Pointsbreak
i hate to have to keep asking questions but i feel like i am really close so can someone tell me what i am missing thanks
def loopy(items):
for item in items:
print(item)
if item == "STOP":
break
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Alex,
Yes, you're pretty close. All of your code is correct but you have to think about the order of your statements.
What if item
is equal to "STOP"? You're going to print "STOP" then you check if it's equal to "STOP" and break out.
The challenge doesn't want you to print "STOP". So you have to check for that first and break out. Otherwise, you can print the item.
Alex Durham
Courses Plus Student 456 PointsThanks for the response but im still not sure what to do are you saying i have some stuff out of order? Thanks
Jason Anello
Courses Plus Student 94,610 PointsYes, you have to do your if
check first and then the print. You have to swap the if block and the print statement.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsRemember to mark the question closed (by selecting a "best answer") once you are satisfied with an answer.