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

Breaks challenge

Not sure why i am not passing?

breaks.py
def loopy(items):
    for loppy in (items):
        if character at index o == "a":
            continue
    print(current member)
Brian Boring
Brian Boring
Courses Plus Student 3,904 Points

The challenge is as follows;

Same idea as the last one. My loopy function needs to skip an item this time, though. 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. Otherwise, print out the current member. Example: ["abc", "xyz"] will just print "xyz".

You are moving in the right direction, except for a few missteps. You are correct that you need to cycle through (items). You have chosen to cycle through items applying each item to the variable "loppy". (Not sure if you meant to call it loopy, but that doesn't really matter, apart from slightly confusing to read. I would name it "item".) With each cycle of (items) contents, you are correct that you want to compare the item at index 0 with "a", but your syntax is off. If I was cycling through (items) using the variable "item", I would call the thing within items at the 0 index "items[0]". So apply that to what you're doing here. Also, "a" should be in parenthesis.

Lastly, you want to say, if this happens, continue... ELSE, print. Also remember that indexing matters in python.

I hope this helps without giving too much of it away.

2 Answers

first of all, instead of "character at index 0", we have to use item[0], which is the proper way to reference the place in the location in the Item string. Also, along with that when you are printing the item, you must print this "item" that we are using. The code should look something like this.

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

Thanks got it now, also going to back track and do some reviewing.

There is a few things wrong with your code that I can see. Take another look at line 3 and line 5.