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 trialMichael Dinnall
6,730 PointsNeed help, got stuck for a while now. maybe i don't get the logic compltely
def loopy(items): for item in items: if item[0] == "a": print item
print loopy(items)
def loopy(items):
for item in items:
if item[0] == "a":
print items
1 Answer
dojewqveaq
11,393 PointsHey Michael! The task is asking you to NOT print if the first char of item is 'a'. So, when the first char == 'a'. Skip it(continue). Else, print it. Here is how I solved it:
for item in items:
if item[0] == 'a':
continue
else:
print(item)
Cheers!
Mike Wagner
23,559 PointsMike Wagner
23,559 PointsYou could also simply do an
if item[0] != 'a':
to skip it, but your approach might be more "Pythonic".. I couldn't say.