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 trialAlex Crump-Haill
7,819 PointsSame issue with similar problem to before!
Apparently cannot convert a str into int implicitly - which I knew - but not sure why it would be the case here!
def loopy(items):
# Code goes here
for item in items:
if item.index(0) == "a":
continue
print(item)
2 Answers
Steven Parker
231,269 PointsThe .index function searches a list for an item. The item should be the same type as the elements of the list.
But that's not what you want here anyway, you already know the index. You want to get the item at index 0.
That's done by subscripting, using the index in brackets (like: "item[0]
").
Petko Delchev
7,417 PointsHi all,
look I did the subscripting, but still bummer...
def loopy(items): # Code goes here for item in items: if item [0] == "a": continue else print(item)