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 trial

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

gee cee
gee cee
1,968 Points

I think this problem is worded incorrectly for the example, it says every even number but the example is using odds

Question is phrased like so:

"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]."

This is confusing because the example is using odd numbers for the expected output.

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

def first_and_last_4(input_list):
    return input_list[:4] + input_list[-4:]

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

def reverse_evens(input_list):

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The question says the even index and then it gives an example. All the odd numbers are at even indexes. The element at the index of 0 is 1, the element at index of 2 is 3, and the element at index 4 is 5. But we really could have used any example. If I used this as the example input:

["hi", "there", "gee", "cee"]

I would expect to get back:

["gee", "hi"]

This is because "hi" and "gee" are at even indexes (0 and 2) respectively.

Hope that helps! :sparkles: