How can I reverse my_list?



How can I reverse my_list?


We don’t need to create a new list and then reverse it. Instead, all we need to do is assign the reversed version of my_list to a new variable named backwards. To reverse a list, we can take a look at the example given:

letters = ['A', 'B', 'C', 'D', 'E']
print letters[::-1]

The stride index is all we need to specify.

FAQ: Learn Python - Advanced Topics in Python - Reversing a List