Because -0
in Python is 0
.
With 0
you get first element of list and
with -1
you get the last element of the list
list = ["a", "b", "c", "d"]
print(list[0]) # "a"
print(list[-1]) # d
You can also think it as shorthand for list[len(list) - x]
where x is the element position from the back.
This is valid only if 0 < -(-x) < len(list)
print(list[-1]) # d
print(list[len(list) - 1]) # d
print(list[-5]) # list index out of range
print(list[len(list) - 5]) # a