Python Python Collections (2016, retired 2019) Slices Slice Functions

Derick Ho
Derick Ho
3,113 Points

Why does the prompter tell me that my solution is incorrect however is reviewed my answer and it returns the correct val

I am having a problem with reverse evens specifically. I am supposed to return a list that is the reversal of the original and only the even indexes of that list. However after i completed the task it tells me it is incorrect.
def first_4(whatever):
    return whatever[0:4]

def first_and_last_4(single):

    final = single[0:4]
    return final

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

def reverse_evens(single):
    reverse = single[::-1]
    final = []
    for item in reverse:
        if(reverse.index(item) % 2 == 0):

    return final

1 Answer

to get a even index on the list u need to advance with 2 steps [0::2] and to reverse it add [-1]

Derick Ho
Derick Ho
3,113 Points

Thank you for your answer, I changed my solution to list[::-2] which will do the specified task but it still tells me it is wrong. I ran my code and it is correct but for some reason the problem won't accept my solution.