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

I'm not sure how to write the index part of this challenge. Please help thanks!

How do I tell python to look at the index 0 part of the item?

breaks.py
def loopy(items):
    # Code goes here
    for item in items:
      print(item) 
    if index(item) == "a":   # How do I write the index 0 thing?
      continue

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,426 Points

The simple syntax is using the slice index item[0]

In your posted code, the if statement needs to be indented so it is inside the for loop.

Also, the if ... continue statement needs to be before the print statement otherwise it will print every loop iteration.