a = [10, 11, 12, 13, 14, 15, 16, 17, 18]
print(a[-3:1])
why empty is coming
a[-3:1:-1]
In your case step (by default is 1) means moving 1 step forward
You want to go from -3 to 1 index then you need to use step in reverse ie (-1)
a = [10, 11, 12, 13, 14, 15, 16, 17, 18]
print(a[-3:1])
why empty is coming
a[-3:1:-1]
In your case step (by default is 1) means moving 1 step forward
You want to go from -3 to 1 index then you need to use step in reverse ie (-1)