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!
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 trial
Trevor Wood17,828 Points
I don't understand why this didn't work
So I finally got this code challenge after googling a bit. But I don't see why my original code didn't work.
# Original def loopy(items): # Code goes here for item in items: if item.index("a") == 0: continue else: print(item) # Passed code def loopy(items): # Code goes here for item in items: if item.startswith("a"): continue else: print(item)
Kourosh Raeen23,732 Points
Because the index() method throws a "ValueError: substring not found" error if the item doesn't contain the letter a, whereas the startswith() method returns False.
James GillCourses Plus Student 34,935 Points
It's as @kourosh said: your failing method returns an error, but your passing method returns a boolean (True or False). The failing method can't "continue".