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 trialdima Dima
901 Pointswhere is the mistake here
I need to loop through the list and print the item's index 0 if it Is not an A
def loopy(items):
for item[index]:
index=0
if items[index]=a:
continue
else:
print (items[index])
index=index+1
print (itemes(index))
2 Answers
Cindy Lea
Courses Plus Student 6,497 PointsYou have a few things different & the code could be simplified to this:
def loopy(items):
for item in items:
if item[0] == "a":
continue
print(item)
'''
Russell Sawyer
Front End Web Development Techdegree Student 15,705 PointsYou have the right idea but you need to make a few changes. The for loop allows you to iterate through a list of items using a "throw away" variable, in this case 'item'.
def loopy(items):
for item in items: # iterate through items
if item[0] == 'a': # == compares the two items to see if they are the same. = assigns value to variables, but any string needs to be in quotes or it will produce an error
continue
print(item)