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

I'm not understanding the question. I thought it was asking to skip any element on the list that has a value of "a".

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

2 Answers

jrabello
jrabello
17,917 Points

hey Yaumel, your code is almost right, you're only missing the index part, you need 2 check if 'a' is at index 0 of item

Ok, I rewrote the code and tried it out on the terminal and it worked(printed out all of the items with the exception of the first one if it was "a"). However, I'm still getting it wrong on the challenge.

def loopy(items):
    for item in items:
      if items.index(item) == 0 and item == 'a':
        continue
      else:
        print(item)
jrabello
jrabello
17,917 Points

to check the first element of item we use indexing -> item[0] :)