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 trialDennis Murekachiro
2,917 PointsOK, try this one on for size: create a new function named odds that ret
i keep getting an oops message. where am i going wrong
def first_4 (iterable):
return iterable [0:4]
def first_and_last4 (iterable):
return iterable [:4] + iterable [-4::1]
def odds (iterable):
return iterable [1::2]
3 Answers
Dennis Murekachiro
2,917 Pointsdef first_4 (iterable): return iterable [0:4] def first_and_last4 (iterable): return iterable [:4] + iterable [-4::1] def odds (iterable): return iterable [1::2]
A Wood
1,666 PointsYou just had a typing error on your second function, it should be "first_and_last_4" you have "first_and_last4". Here is your code with the error fixed.
def first_4 (iterable):
return iterable [0:4]
def first_and_last_4 (iterable):
return iterable [:4] + iterable [-4::1]
def odds (iterable):
return iterable [1::2]
Marie Lu
179 PointsA Wood Wouldn't it need to be [0::2]
because then it starts from 1 and then add two it becomes 3 and then add 2 it becomes 5, etc?
def odds (iterable):
return iterable [0::2]
Dennis Murekachiro
2,917 PointsThank you