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 trialSam Royal
564 PointsWhat's wrong with this code?
Did I write the index wrong?
def loopy(items):
# Code goes here
for item in items:
if index(0) = 'a':
continue
else:
print(item)
1 Answer
Luke Pettway
16,593 PointsYou have a couple of things going on which are preventing you from passing:
def loopy(items):
# Code goes here
for item in items:
if index(0) = 'a': #<--- 1. Since you single version of the collection is item, you should use item and not index
continue # 2. When you need to access an index of a string/array you use [] instead of (), item[0].
else: # 3. The singular = equals sign is an assignment operator. You want to evaluate the value of the
print(item) # item index by using either == or === for strict checking. I usually default to using ===.
Let me know if that helps you at all. Sometimes these challenges can be tricky if there is more than one problem and the error you get is very vague.