+ 1
lists slicing
sqs = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] print(sqs[7:5:-1]) please tell me how this works
2 ответов
+ 7
The formula says: return the list's elements from 7 to (but not including) 5, stepping backwards by 1.
Element index 7 is 49, next (backwards, so index 6) is 36 and that's it.
0
The code will output [49, 36] this is because the -1 says that the list should be read through backwards