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

Ashley Keeling
Ashley Keeling
11,476 Points

does any one know why this code isn't working

I don't know why it isn't working

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

3 Answers

Steven Parker
Steven Parker
231,275 Points

The instructions say to skip If the character at index 0 of the current item is the letter "a".

That's another way of saying "if the first letter is a". But this code only skips an item if the name is exactly "a".

Since you only asked why it isn't working I assume you don't want a spoiler and can take it from here.

Oszkár Fehér
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Oszkár Fehér
Treehouse Project Reviewer

Hi Ashley, The loop it's ok and it will print out the correct answer but just in case of characters, list of characters. The quiz mentions that If the character at index 0 of the current item is the letter "a", which it means every string what starts with the character "a", it's a little bit tricky. So we can call this method:

if item.startswith('a', 0):     <---letter 'a' at index 0--->
    continue

I hope this will help you.Happy coding

Steven Parker
Steven Parker
231,275 Points

Glad to help. And happy coding!