+ 1
How does this works?
A tuple into a list the print the index https://code.sololearn.com/c5r35LxEa8pP/?ref=app
6 ответов
+ 1
k[4:2] is empty because the start number is bigger than the stop number. but it works if you add -1 as third number which is step . Default is 1 if you don't mention any. So as a default it moves from 4 forward so it prints empty list
+ 6
k[1:3] returns[ 2,3 ]
And k[4:2]) returns empty
So [2, 3] only...
+ 5
k[4, 2] start index is 4 and end index is 2 so already 4 exceeds 2. So no starts slice
See list[ start, end, step_count ] : list slicing starts at start index, until end index by taking step_count for next index.
+ 1
Why k[4:2] returns empty?
+ 1
Thanks Jayakrishna that's the best answer!