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

breaks.py: I am now lost. Please help!

Hello! I am trying to follow the challenge step by step and now lost.

Can you please help and explain so I can easily digest the resolution?


def loopy(items):
    # Code goes here
    for item in items:
        if 0 == 'a':
Sara Watson
Sara Watson
Courses Plus Student 3,713 Points

Have a look at your condition statement,

if 0 == 'a':

That will never be true, right? What you want to do is use item to access the character at index 0.
You are close.

Sara has pinpointed the crux of the problem. I'll add a bit more. Using indexes is a very useful way to access bits of code. So getting comfortable with it will serve you well. You have the 0. That's a start.

  • 1: What is the thing you want the 0 index of.
  • 2: How will you access it.

2 Answers

Got it! Thank you so much!!

def loopy(items): # Code goes here

for item in items:
    if item[0] == 'a':

That's cool, I didn't think about leaving out the else clause, but that worked just fine :D

Thank you John and Sara! Great pointers!