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 trialUmair iqbal
910 PointsWhats wrong
whats wrong
def loopy(items):
for words in items:
print(items)
if item == "STOP":
break
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! I'm not sure if you're on Step 1 or Step 2 of the challenge. If you're working on step 1 you'll need to remove the if
statement. Step 1 only requires that we print out each individual items in the items list. You've chosen to name each individual item words
. That should be what you're printing out.
If you're working on step 2 the same thing applies as step 1. Your item is named words
. But you're comparing item
to "STOP". But the variable item
is undefined in your code. You only have defined words
and items
. Also, check your order and indentation. The check for the words
being equal to "STOP" needs to come first, otherwise it will print out "STOP" as well. And the if
statement should be indented inside the for loop.
I think you can get it with these hints, but let me know if you're still stuck!
Umair iqbal
910 PointsCouldnt thank you enough
Umair iqbal
910 PointsUmair iqbal
910 PointsSo i should be comparing words with item, i did that but im still getting that annoying bummer the identation is four spaces right i checked that the order is def then for words then if words=="STOP": break not working
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherAt this point, I'm unsure what your code looks like and if it might be simply an indentation error. But using the variable names you defined, this is how the completed code looked:
Note this is for Step 2 and will not pass Step 1. We start by defining a function named
loopy
that takes a list nameditems
. For every individual item namedwords
we will comparewords
to "STOP". If the item in the items list is "STOP" we break without printing anything. Otherwise we print the item or, as you named it,words
.Hope this clarifies things!