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 trialPaulhan Carre
1,368 PointsWhat am i doing wrong?
need help with last part
def first_4(a):
return a[:4]
def first_and_last_4(fal):
return first_4(fal) + fal[-4:]
def odds(o):
return o[1::2]
value[2,4,6,8,10]
def reverse_evens(re):
return [::-1]
reverse_evens(value)
1 Answer
Steven Parker
231,236 PointsYou need to return only every other value.
This approach will only reverse the list, but you still need to return only the items that originally had even-numbered indexes.
You'll also either need to calculate the starting position based on the list size, or you'll need to extract the evens first and then reverse them in a separate step.
Jose Aguirre
14,866 PointsJose Aguirre
14,866 PointsIt seems like the first three are correct but the last one needs a little extra. Right now you are just returning the list in reverse, remember you only want elements with an even index returned so set the list equal to [::2] so that it odd index is not added to list. This is what I got.
Hope this helps. BTW, nice job calling the first function in the second function, that did not occur to me, but it is quite elegant.