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.

reverse even index: did it right but can't proceed. Anyone can help me with this?

when i pass a list as the exemple [1,2,3,4,5] i got the right answer as [5,3,1] but when i click on CheckWork, i can't proceed. Why?

this is the question stem: Make a function named reverse_evens that accepts a single iterable as an argument. Return every item in the iterable with an even index...in reverse.

For example, with [1, 2, 3, 4, 5] as the input, the function would return [5, 3, 1].

You can do it!

slices.py
```def first_4(lista):
return (lista[:4])

def first_and_last_4(lista):
last_four = len(lista) - 4
return (lista[:4] + lista[last_four:])

def odds(lista):
return(lista[1::2])

def reverse_evens(lista):
return(lista[-1::-2])
```

2 Answers

Hey, Diego. Here's a link to another post that should clear things up for you:

https://teamtreehouse.com/community/code-challenge-slice-function-task-4-solution-not-accepted

I got it now, thanks Matt.

Chris Freeman suggested to use this function

```def reverse_evens_2(items):
return items[::2][::-1]
```

but I use this (below) because was easier for me to undertand where I did it wrong

```def reverse_evens(lista):
evens = lista[0::2]
evens.reverse()
return(evens)
```