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 trialKody Low
13,501 PointsHow do I print out the things in the items list?
I'm having trouble using a for loop to do this, what should this look like?
def loopy(items):
# Code goes here
for item:
print(items)
if items == "STOP":
break
1 Answer
Elad Ohana
24,456 PointsYour for loop is not formatted properly; since you are trying to iterate over the items list, you need to go over each single item. Your for loop should instead look something like this:
for item in items:
if item == "STOP":
break
print(item)
Note that I am using the word item instead of items in for my print and if statements, as you want to check against each individual list item rather than the whole list. Hope this helps.
Kody Low
13,501 PointsKody Low
13,501 PointsI'm supposed to print the things in items and stop the loop when the thing in item is "STOP"