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

Soufiane Bdaoui
Soufiane Bdaoui
9,602 Points

Help me understand the error in this phyton code challenge

I tried to search for similar problems but I really can't seem to understand the difference between my code and what other people used to pass the code challenge.

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

3 Answers

olegovich7
olegovich7
6,605 Points

Soufiane, your code is fine, you just have two small typos:

  1. after if statement, continue should have 4 more spaces in front of it (indentation). Because there's no spaces it "continue" executes every single time with a loop and not when if statement is true
  2. after else statement you have a space before colon
Soufiane Bdaoui
Soufiane Bdaoui
9,602 Points

Thanks for the answer, sadly it's not enough to pass the code challenge. I got this error message:

Bummer! Didn't find the right items being printed.

olegovich7
olegovich7
6,605 Points

Maybe there is some extra space somewhere. Use this, passes challenge for me.

def loopy(items):
    for item in items:
        if item[0] == "a":
            continue
        else:
            print(item)
Soufiane Bdaoui
Soufiane Bdaoui
9,602 Points

I finally understood that there was a problem with the indentation. Thanks guys.