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 trialConner Williams
Courses Plus Student 3,305 PointsIs this anywhere near being correct?
after taking some time to think about this one, I feel I might be getting somewhere. Still completely unsure though.
def loopy(items):
# Code goes here
for item in items:
print(item)
if index(0) == 'a':
continue
else:
print(current number)
2 Answers
Steven Parker
231,236 PointsYou won't need the "else" or the second "print" (plus that phrase "current number" doesn't mean anything to the program).
Then you need to re-order your lines so the test is done before the print, and indent the test more to put it inside the loop.
Finally, instead of "index(0)" you need "item[0]" to get the first letter of the item.
I'll bet you can get it now without an explicit code spoiler.
Haydar Al-Rikabi
5,971 PointsTo demonstrate Steven's reply, see the following code:
def loopy(items):
for item in items:
if item[0] == 'a': # Use square brackets [] rather than parentheses ()
continue
print(item) # If the condition above fails, then this line is executed