Python Python Basics (2015) Shopping List App Break

Steven Gutierrez
Steven Gutierrez
Full Stack JavaScript Techdegree Student 5,688 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 143,586 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: