Learn
Advanced Topics in Python
Reversing a List

We have seen that a positive stride progresses through the list from left to right.

A negative stride progresses through the list from right to left.

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

In the example above, we print out ['E', 'D', 'C', 'B', 'A'].

Instructions

1.

Create a variable called backwards and set it equal to the reversed version of my_list.

Make sure to reverse the list in the editor by passing your list slice a negative stride, like in the example above.

Folder Icon

Take this course for free

Already have an account?