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 trial

Python Python Basics (2015) Shopping List App Break

Didier Borel
Didier Borel
2,837 Points

for loop print items

i don't quite see what I am doing wrong here

breaks.py
def loopy(items):
    for:input("> ")
    print(input)
    if: input=="STOP":
        break

3 Answers

Tatiana Perry
Tatiana Perry
17,156 Points
def loopy(items):
  for item in items:
    if item == "STOP":
      break
    print(item)

The if/break statement needs to be inside the loop before print.

Didier Borel
Didier Borel
2,837 Points

thxs Tatiana,

2 questions. what is the difference between == and = (1 or 2 equal signs)

and how do we know that item is a word python will understand, and differentiaite from items? is there a list of words or variables that python knows. ?

thxs

Steven Parker
Steven Parker
231,269 Points
  1. Two signs (==) is a test: "are these equal?". Just one = is an assigment: "copy the right side to the left side".
  2. You're talking about reserved words / language keywords. They are listed in the offical python docs.
Didier Borel
Didier Borel
2,837 Points

this Steven. that answers my question