Python code issue

a = [1,2,3,4,5,6,7,8,9]
print(a[-1:-5])

Why output is empty list???

1 Like

@mick4mayank

list[start:stop:step] means give me elements starting at **start** and incrementing by **step** until you hit **stop** .

Code is returning the empty list as it does reach the stop value.

1 Like