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

Challenge Task 1 of 1: If character at index 0.

Hello Team,

I'm trying to see where I'm going wrong with this. I did the "for" loop; then "if" for characters that are at index 0; then continue and print.

Thanks

def loopy(items): #"for" loop of characters in items for char in items:

#"if" the character at index 0 is 'a'; then continue
if char[0] == "a":
    continue

#otherwise print current member else: print(char)

breaks.py
def loopy(items):
    #"for" loop of characters in items
for char in items:

    #"if" the character at index 0 is 'a'; then continue
    if char[0] == "a":
        continue
   #otherwise print current member
    else:
        print(char)  

2 Answers

Your code is fine, it's just Python is picky about indentation. For example, this:

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

Is way different than this (which is the solution to the challenge):

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

You always need to indent your code properly or Python will cause an error :)

Good luck! ~alex

Ohhh...Awesome!! I was about to pull my hair off my head...lol...Thanks Sir

No problem! :)