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 trialFaisal Julaidan
13,944 Pointswhat'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
def loopy(items):
for item in items:
if item.index(0) == "a":
continue
print (item)
2 Answers
Christian Loveridge
Python Web Development Techdegree Student 7,538 PointsThink 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
13,944 Pointsohhh 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
Faisal Julaidan
13,944 PointsFaisal Julaidan
13,944 Pointsaha, so it not like Java and some other language so when do I use index with strings? Never?