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!
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
Han LiPython Web Development Techdegree Graduate 14,817 Points
I got the following error
"Bummer: Didn't get the right values from reverse_evens"
def first_4(items): return items[0:4] def first_and_last_4(items): return items[0:4] + items[-4:] def odds(items): return items[1::2] def reverse_evens(items): return items[::-2]
Steven Parker225,712 Points
This strategy will work with some test data, but not every time.
To create a function that will work reliably with all data, there are two basic approaches:
- compute which item to start with based on the size (or actually the "even or odd-ness") of the list, or
- use one slice to extract all the even indexed values, and then another slice to reverse them
Either method will work when implemented correctly. Bonus hint: the second method might be easier to implement.