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

Kennedy Otwenyo
Kennedy Otwenyo
785 Points

What am I missing?

I have edited the code but I am still getting the same response "Didn't get the right items to print"

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

3 Answers

Yes, you are very close. In this answer, I'm basically saying the same thing as Jason Anello.

Jason said clearly that:

The challenge is asking you to check index 0 of the current item that you're looping over. You're checking index 0 of the items argument that was passed in.

I am going to simplify this to be easier to understand.

Look at this line of code you've written:

if items[0] == "a":

Note: I modified it a little to look prettier, but it does the same thing.

Now, let's read what the challenge wants: (I copied this directly from the code challenge.)

Loop through each item in items. 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.

Okay, now let's look at what your code is doing: (I wrote this myself.)

Loop through each item in items. If the very first element in the items list is the letter a, don't print the element.

You see the difference? For the first example, the loop goes through every element in the list. If the current element has the letter a, don't print the element, else print the element.

In your code, it won't print anything if the first element in the list is "a".

Check the first element of the "temporary variable" (in your code it's called item) instead of the list the loop is iterating through and you should pass :smile:

I hope this helps :grin:

If this doesn't help, reply with your second attempt's code and I'll try to help more. :+1:

:dizzy: ~Alex :dizzy:

Hi Kennedy,

The challenge is asking you to check index 0 of the current item that you're looping over.

You're checking index 0 of the items argument that was passed in.

I don't see how this answer is down-voted, since Jason Anello clearly explains how the code is wrong.

Don't expect anybody to give you answers to challenges straight. If you just give an answer without an explanation, the person asking the question can just copy-and-paste the passing code and don't even know what's wrong in their own code.

The best way to learn programming is to try to challenge yourself. If you got the answer from somebody else, you aren't challenging yourself.

Kennedy Otwenyo
Kennedy Otwenyo
785 Points

Hi Guys, Thank you all for the input, I now see my error. I also appreciate the approach of explaining the answer as stated by Alexander rather than solving the problem. I do agree this approach has encouraged me to understand and even learn further. Good looking out!