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

Python Python Basics (2015) Shopping List App Continue

Carlos Parra
Carlos Parra
792 Points

Need help with loopy function. My code works in Workspaces, i don't understand why, i can't pass the challenge.

Not much to say, it works. Here is the code i tried on Workspaces.

List = ['apples', 'bananas']

def loopy(items): for item in items: if item.index('a') == 0: continue print(item)


def loopy(items):
    # Code goes here
    for item in items:
        if item.index('a') == 0:

2 Answers

Steven Parker
Steven Parker
227,167 Points

:point_right: It "works" with that particular test data, but the challenge is going to test it with other data (try including a word in your test list that has no 'a' in it).

The challenge says to check If the current item's index 0 is the letter "a", but you seem to be checking if the index of 'a' is the number 0.

Also remember that the operator for simple indexing is a pair of brackets [].

Carlos Parra
Carlos Parra
792 Points

Sigh, yeah, you're right. But it is basically the same in the real world i bet. i just switched up how it was done. Thanks