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 trialBruno Paris
3,568 Pointswhat am i doing wrong
i don´t see the mistake here, what could it be?
def first_4 (whatever):
return whatever[0:4]
def first_and_last_4 (whatever):
s= whatever[:4]
a = whatever[-4:]
return s+a
def odds (whatever):
c = list(whatever)
return c[1::2]
def reverse_evens (whatever):
c = list(whatever)
return c[::-2]
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou are close! Currently, the code is returning every other item from the back of the list. This may or may not be the even-indexed items because it depends on the length of the collection.
>>> reverse_evens([0, 1, 2, 3, 4, 5])
[5, 3, 1]
>>> reverse_evens([0, 1, 2, 3, 4, 5, 6])
[6, 4, 2, 0]
It's better to use a two-step approach. Get the even-indexed items, then reverse it.
Post back if you need more help. Good luck!
Bruno Paris
3,568 PointsBruno Paris
3,568 Pointsdone! thank you chris