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

Faisal Julaidan
Faisal Julaidan
13,944 Points

what's wrong with my code for the challenge ??

here is my code for the second challenge https://teamtreehouse.com/library/python-basics/shopping-list-app/continue

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

2 Answers

Christian Loveridge
seal-mask
.a{fill-rule:evenodd;}techdegree
Christian Loveridge
Python Web Development Techdegree Student 7,538 Points

Think of Strings as lists--to get the first index in a list, you use:

some_list[0]

To get the first char out of a string, do the same thing:

if some_string[0] == "a":
     do_something()
else:
     do_something_else()
Faisal Julaidan
Faisal Julaidan
13,944 Points

aha, so it not like Java and some other language so when do I use index with strings? Never?

Faisal Julaidan
Faisal Julaidan
13,944 Points

ohhh i figured it out now the method index return a integer and inside the parentheses i specifiy the letter that I want to return its index