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

Help with challenge

the question is: "My loopy function needs to skip an item this time, though. Loop through every item in items. If the current item's index 0 is the letter "a", continue to the next one. Otherwise, print out the current member."

but it seems I don't really understand what they look. Please help.

breaks.py
def loopy(items):
    # Code goes here
    indexo = 0
    for cosa in items:
      if cosa == 'a' and indexo == 0:
        indexo += 1
        continue

      print (cosa)
      indexo += 1

1 Answer

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

Hi Pablo Donetch!

You're doing great! I've modified your code a bit and using your variable names as much as possible. To begin with, the indexo variable is unnecessary. They're sending you an iterable item. And every iterable item has a built in index. Now I'm going to show you the code and walk you through it:

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

So here we have loop which takes some sort of iterable item. Presumably a list of strings. Now for every "cosa" in our items list we're going to check the 0 index and see if it's a lower case a. We do this by using cosa[0]. If it is a lower case a, we're going to use continue to skip it. Otherwise we will print out our "cosa". What this will result in is a print of everything in items that doesn't start with a lower case a. Hope that helps! :smiley: