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

First Slice not working [Solved]

testing_list = [1, 2, 3, 4, 5]

def reverse_evens(iterable4):
    list = iterable4[::2]
    list = sorted(list)
    return list[::-1]

print (reverse_evens(testing_list))    # EXPECTING 5,3,1 and it works!

The code runs correctly, but the system does not accept this method ?

2 Answers

Works once I took out

list = sorted(list)

Glad to hear it's working, just a reminder that list is a reserved word in python for the list class, so best to avoid using for variable names; I tend to use lst or something_list :)