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

Kade Carlson
Kade Carlson
5,928 Points

What did i do wrong here?

Can someone please explain to me what I did wrong?

breaks.py
def loopy(items):
    for item in items:
        if item[0] == "a":
            continue
    print(item)
Jay Norris
Jay Norris
14,824 Points

You aren't "printing the current member", maybe with an else in the loop.

4 Answers

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Kade,

Please see the code below that I used to pass this challenge:

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

It looks like you are only missing the else statement.

Hope this helps! Happy Coding!!!

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

Hi there, Kade! You're doing terrific! Please note that I have some comments regarding the answers you've received thus far. First, you can use continue in any kind of loop or with an if statement. And that's what I used for this challenge. Secondly, you do not need the "negative" or not operator for this. Third, you do not necessarily need an else statement.

The only problem with your code is indentation. You've put the print statement outside the for loop. So item is now out of "scope". The variable item is a temporary variable that only exists while that for loop is executing. Once the for loop completes execution, that variable disappears. So, if I indent your print statement to be inline with the if statement, your code passes with flying colors! Take a look:

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

Hope this helps, and keep coding! :sparkles:

Blayne Holland
Blayne Holland
19,321 Points

unless each "item" is an array nothing is going to print out because the index of 0 does not exist.

Also the print() statement isn't in the for loop block so you might also get an error saying the variable does not exist.

Brecht Philips
Brecht Philips
8,863 Points

Try the negative if item [0] != 'a' Print item

Continue is typically used with a while loop not in an if statement