0

List slicing question...can anyone pls explain me the procedure?

squares = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] print(squares[9:5:-1]) Output [81, 64, 49, 36]

30th Jun 2021, 7:09 PM
Sudipta Dhara
Sudipta Dhara - avatar
2 ответов
+ 3
30th Jun 2021, 7:43 PM
minirkk
minirkk - avatar
+ 2
Get a slice of `list` <squares> from 9th item (value 81) down to (not including) 5th item (value 25). The list items to slice will be read in reverse order due to the use of -1 value in stepping.
30th Jun 2021, 7:44 PM
Ipang