Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Shopping List App Continue

What am I not understanding? Python Basics Continue Code Challenge.

I keep getting "Bummer! 'builtin_function_or_method' object is not subscriptable" and I have no idea what it is referencing in my code so i don't know where to begin tinkering. Help!

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

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,692 Points

Hey Andrew.

Sorry, my original response was kicked out by the update to the Database servers...

There are a couple of things going on with the code.

  • First -- .index is not a valid method. To access a certain index of an array, you just need the square brackets [] with the index number enclosed.

  • Second, with you print statement, you want to print out the item, which is the temporary variable assigned to the individual values in the array. You currently have items, which is the actual (and complete) array.

So the completed code for the challenge is:

def loopy(items):
    # Code goes here
    for item in items:
      if item[0] == 'a':
        continue
      else:
        print(item)

I hope that makes sense. If you have any other questions, feel free to post in the forum. Keep Coding! :)

Why yes! Thank you Jason. I have the index function variations written correctly in my notes. Your other fix on the print line also makes sense, although I am a little fuzzy on using singular and plural words as variables. Thank you for your help.