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 trialCross Ender
9,567 PointsI simplicitly can't figure this out.
.
def first_4(itt):
return itt[:4]
def first_and_last_4(itt):
return first_4(itt) + itt[-4:]
def odds(itt):
return itt[::2]
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsremember that the first index is 0 which is even, and that it is also the default if you don't put a starting index. when you got the first four, you sliced with [:4] to get indices 0,1,2,3.
Unsubscribed User
16,600 PointsYou need to set a starting index of 1 to capture the odds
def odds(itt):
return itt[1::2]