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 trialLaknath Gunathilake
1,860 PointsHaving Trouble Skipping an item
I'm not sure if items.index('a')==0 is the way to solve this problem.
def loopy(items):
while True:
items.index('a')==0:
continue
else: print items
1 Answer
Haider Ali
Python Development Techdegree Graduate 24,728 PointsHi, this challenge asks you to loop through items
and check if the first letter in each item is equal to 'a'. If so, then continue. However, if not, call the print()
function on that item:
def loopy(items):
for item in items: #for every item in items
if item[0] == "a": #checks if the first letter is a
continue
else:
print(item)
You can do this, however, the else
block is not necessary since if the first letter is a, it will skip the else block anyways.
Tagging Kenneth Love since there seems to be a mistake on this challenge. It asks you to print out every member in items whereas this does not actually pass the challenge. To pass the challenge you should just print out that item instead of the whole list.
Thanks,
Haider
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherThanks for the feedback. I updated the prompt a little to make it more clear.
Matthew Reisch
5,671 PointsMatthew Reisch
5,671 PointsI had trouble with this question as well. The wording is a little ambiguous. Perhaps it should be reworded so that it is obvious that the items list is filled with strings and that we are checking the substring (in this case index 0) of each string item for the existence of the character 'a'.
Overall great course experience so far, but this question was not easy to decipher.
Best, Matt