0
why List Slices gives me empty output
squares = [0,1,2,3,4,5,6,7,8,9,10] print(squares[7:5]) output is [] squares = [0,1,2,3,4,5,6,7,8,9,10] print(squares[3:6:-1]) output is []
1 ответ
+ 2
Because there is no output.
7:5 try's to return everything from index 7 to index 5, but it reads from left to right, so 5 is before 7 and your code fails. Try: squares[7:5:-1]