Welcome to the Treehouse Community
Looking to learn something new?
Hi, I am a complete novice at coding and I am stuck on this problem. I can figure out what I am doing wrong with question two. Can someone please explain what I am doing wrong? Here is the code that I have done and from everything, I can find on Google it seems to be right but I keep getting the error message saying that it is wrong.
def loopy(items): for item in items: print(item)
if item == "STOP": break
def loopy(items): for item in items: print(item) if item == "STOP": break
The code itself is fine. The issue is that even though it is not explicitly stated the task expects the loop to exit the second the STOP item is encountered, in other words the
if check is meant to be placed before the
So if you move them around like this:
def loopy(items): for item in items: if item == "STOP": break print(item)
Then the code will work.