0
What are negative indices?
In python language
2 Réponses
+ 1
Let’s take a list for this.
>>> mylist=[0,1,2,3,4,5,6,7,8]
A negative index, unlike a positive one, begins searching from the right.
>>> mylist[-3]
6
This also helps with slicing from the back:
>>> mylist[-6:-1]
[3, 4, 5, 6, 7]
0
Did you just answer to your self? and why is -3 equivalent to 6? shouldn't it start from 0?(just curious, I don't know python)