What does [::-1] do?

Last updated 3 years, 2 months ago | 1421 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]