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 trialMiha Puc
1,136 PointsHow is this def reverse_evens(a): e=a[::2] e.sort(reverse=True) return e
My code achives what the task requires does it not?
def first_4(a):
c=a[0:4]
return c
def first_and_last_4(a):
c=a[0:4]
l=c+a[-4:]
return l
def odds(a):
d=a[1::2]
return d
def reverse_evens(a):
e=a[::2]
e.sort(reverse=True)
return e
1 Answer
turaboy holmirzaev
19,198 Points- Your answer is right if all your inputs are in sorted order.
- the challange is not asking to sort the list. Instead it is asking to show the elements in reverse order
- the challenge is about slicing the list so better use slicing options to reverse [::-1] reverses the list elements
- Your answer will be right if you just use reverse() method on e instead of sort(reverse=true)