+ 1

Wouldn't it be [49, 36, 25, 16]?

Does the list not start from the 8th spot from the right (because 0 is included, 1+7=8) 49, and end at the 5th spot from the right, 16?

27th Feb 2018, 6:51 PM
Doug
3 Respuestas
+ 7
No, it starts at index position 7 (from the left), i.e. 49 then moves to the left and ends just before index position 5 (also from the left), i.e. the last number is index position 6, which is 36, so the output is [49, 36].
27th Feb 2018, 7:16 PM
David Ashton
David Ashton - avatar
+ 1
?!
27th Feb 2018, 6:59 PM
Farshaad Heydari
Farshaad Heydari - avatar
+ 1
Sorry, the question was "what is the output of this code?" sqs = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] print(sqs[7:5:-1])
27th Feb 2018, 7:04 PM
Doug