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

What does this mean?

I have no idea where to even start on this one.

breaks.py
def loopy(items):
    # Code goes here

4 Answers

There's a few keywords in the instructions that give away some of the main points: Loop, If, otherwise (else).

A good way to break the ice when you're blanking is to map out the log with comments:

def loopy(items):
    # for each item in items
        # if something is true:
            # do one thing
        else:
            #do something else

You don't necessarily have to fill them in in order, pick away at the ones you can figure out and work your way down to the more tricky bits

okay I'm getting closer. How do I tackle the "index" part?

An index always starts at 0, and since strings are technically collections, each character has an index:

Here's a sample:

word = "Test"
first_letter = word[0]

okay now how do I skip the line?

You could normally do it with the continue keyword, but I saw Steven's comment on the other thread you posted for this one and he's right, this can actually be done without continue or an else block. Here's my revised logic, the change in the "if" statement is the key:

def loopy(items):
    # for each item in items
        # if first letter is NOT a:
            # print something

Here is what i have right now. It is giving me a "didnt find the right items printed" message. def loopy(items): # Code goes here for item in items: if item[0] is 'a': print(item)

forgot to include "is not". I completed it. youre saving my life right now.

Almost there

  1. The commented line "code goes here" can go
  2. There was a comment in my last post that is the last piece: # if first letter is NOT a:

There's a "not equal to" operator that need to replace the word "is" in your if statement