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

Grace Baecher
Grace Baecher
578 Points

Loop through each item in items again. If the character at index 0 of the current item is the letter "a", continue to th

Loop through each item in items again. If the character at index 0 of the current item is the letter "a", continue to the next one.

breaks.py
def loopy(items):
    if item in items:
        if item == ["a"]:
            continue
            print(item)
       # Code goes here

1 Answer

Valeshan Naidoo
Valeshan Naidoo
27,008 Points
def loopy(items):
    if item in items:          <-- use a for loop since we are looping through each of the item in the items list
        if item == ["a"]:      <-- item should have the index 0, so item[0], we are searching for the first letter of each item,
           continue                    remove the [] around "a" since it's not part of anything, it's just a string.
           print(item)          <-- this shouldn't be indented in the if statement, you can put that in an else statement.                      

so in the end it should look like this:

def loopy(items):
    for item in items:
       if item[0] == "a":
           continue
       else:
           print(item)
Valeshan Naidoo
Valeshan Naidoo
27,008 Points

you can also just forgo the "else", and just do

def loopy(items):
    for item in items:
       if item[0] == "a":
           continue
       print(item)