What does [::-1] do?

Last updated 2 years, 11 months ago | 1174 views 75     5

Tags:- Python

[::-1] is used to inverse the order of a sequence.

>>> my_list = [1,2,3,5,6,7,8,9]

>>> my_list[::-1]
[9, 8, 7, 6, 5, 3, 2, 1]