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 trialJeff Ness
Front End Web Development Techdegree Student 8,921 PointsI'm at a loss. I thought I set up a condition that would skip printing an index item and index "0" if it were an "a"?
I don't know what to do from here.
def loopy(items):
for item in items:
if items[0] == "a":
continue
else:
print(item)
3 Answers
andren
28,558 PointsYour code is correct, you just have a typo in it. You use the word "items" in your if statement rather than "item" which is the thing you are actually supposed to be checking the index of.
If you change "items" to "item" like this:
def loopy(items):
for item in items:
if item[0] == "a":
continue
else:
print(item)
Then your code will pass.
john larson
16,594 Points# I tried the same thing as you
# item in this case is "abc" so it must me item[0]
# not items[0]
# items would be the whole list
def loopy(items):
# Code goes here
for item in items:
if item[0] == "a": # <--- here
continue
else:
print(item)
Jeff Ness
Front End Web Development Techdegree Student 8,921 PointsThanks so much. Much appreciated. I'm on may way
john larson
16,594 Pointsjohn larson
16,594 PointsHey Andren, I didn't see that you already answered this. At least we agree :D
andren
28,558 Pointsandren
28,558 Pointsjohn larson: No worries, I've ended up in the same situation myself numerous times. And it's indeed good that we agree, if we didn't one of our answers would be incorrect which is never fun .