There is this code:
a = [1, 2, 3, 4, 5]
a[2:4:-1] # returns []
a[4:2:-1] # returns [5, 4]
Why statement a[2:4:-1] returns an empty list altough the range is specified?
There is this code:
a = [1, 2, 3, 4, 5]
a[2:4:-1] # returns []
a[4:2:-1] # returns [5, 4]
Why statement a[2:4:-1] returns an empty list altough the range is specified?
If you attempt to use a[2:4:-1] you try to go backward from list index 2 to 4 which will obviously not work.