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 trialMotty Neuwirth
Courses Plus Student 1,315 PointsTask 4 at Slice Functions doesn't pass def reverse_evens(x): arr = x[::2] return arr.reverse()
Modifications like return x[-1::-2] or x[::-2] don't pass as well
def first_4(x):
return x[:4]
def first_and_last_4(x):
return x[:4]+x[-4:]
def odds(x):
return x[1::2]
def reverse_evens(x):
arr = x[::2]
return arr.reverse()
1 Answer
Joshua Tiedtke
5,647 PointsI don't exactly now why .reverse() doesn't work, but instead you can just take your arr and slice it like:
bla = arr[::-1] and then return bla
the -1 walks backwards through the iterable and reverses it.