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

Benjamin Peters
Benjamin Peters
552 Points

How on earth do I do this?

I've been watching the videos and filling out the code as he goes along, but when I get to the challenge tasks I feel woefully underprepared. I have no idea how to accomplish this. I know what he's asking me to do, but I'm not sure how to execute the task. My questions: What am I doing wrong within this challenge task and what am I doing wrong overall? Why do I feel so lost when it comes to the challenge tasks?

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

3 Answers

Kourosh Raeen
Kourosh Raeen
23,732 Points

Hi Benjamin - You can get the current item's index 0 using

item[0]

Also, remember to use == when doing comparisons. Lastly, inside the for loop start with the if statement first and then the print statement, otherwise you end up printing every item and rendering the if statement useless.

Benjamin Peters
Benjamin Peters
552 Points

Well, after tinkering with it this morning. This is what I got:

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

Kourosh Raeen
Kourosh Raeen
23,732 Points

Everything looks good except the printing part. You need to print the current item in the loop so print(items) should be print(item).