Python Python Basics Shopping List App Break

Steven Gutierrez
Steven Gutierrez
779 Points

Am I putting IF statement in the wrong place?

Is IF in the wrong place?

breaks.py
def loopy(items):
    for item in (items):
        print(item)

    if item == "STOP":
        break

1 Answer

Jennifer Nordell
MOD
Jennifer Nordell
Full Stack JavaScript Treehouse Moderator 120,757 Points

Hi there! Yes, it is. Currently your code will print the word "STOP" if it's entered because it does the print before the check. We want to print everything but "STOP" then exit if it is "STOP". Also, your if statement should be inside the for loop.

Hope this helps! :sparkles:

Steven Gutierrez
Steven Gutierrez
779 Points

Thank you that helped alot