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

Sun Min
Sun Min
2,941 Points

Same idea as the last one. My loopy function needs to skip an item this time, though. Loop through each item in items a

am i doing wrong? i can not figure out this challenge!! :(

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

1 Answer

andren
andren
28,558 Points

There are two main issues:

Firstly you have typed "print(items)" instead of "print(item)" in your else statement.

Secondly you are using the index method incorrectly, the index method takes the thing you are looking for as an argument and then returns it's index. You are passing in the index and then comparing what it returns to the character 'a' which is incorrect.

But that is also a somewhat moot point, because the index method is actually not very well suited for this kind of task in the first place. The index method will raise an exception if the character you ask it to find is not present, which is not what you want in a situation like this.

The better way of checking if 'a' is at index 0 is to use bracket syntax like this: item[0] == 'a' , that will retrieve the character at index 0 of the item string and compare it to 'a'.

Sun Min
Sun Min
2,941 Points

Thank you!