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 trial

Python Python Basics (2015) Shopping List App Continue

Ricardo Lousada
Ricardo Lousada
7,487 Points

My code works fine with my tests using spider and it's not working here

The code is:

def loopy(items): # Code goes here for i in range(len(items)): if items[i] == "a" and i == 0: continue print(items[i])

items = ['a','b',"a",2,3,4,5]

loopy(items)

breaks.py
def loopy(items):
    # Code goes here
    for i in range(len(items)):
        if items[i] == "a" and i == 0:
            continue
        print(items[i])

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're close here, but you're checking the incorrect thing. You're checking the entire item in the item list. Let's say for example that the first item in your items array had been 'apple'. The code challenge would want you to skip that one because that word starts with an 'a'. So instead of the item specifically being 'a' it needs to only start with an 'a'.

def loopy(items):
    # Code goes here
    for i in items:
        if i[0] == 'a':
            continue
        print(i)

Keep in mind that you should not define an items array yourself. This will be supplied by Treehouse.

Here we set up our loopy function. For every i in the items list if the first position inside that i (index 0) is equal to "a" we will skip it. Otherwise, we print out i. Hope this helps! :sparkles:

Ricardo Lousada
Ricardo Lousada
7,487 Points

Thank you Jennifer it was very helpfull.