What are negative indexes and why are they used?

Hi, What are negative indexes and why are they used

https://duckduckgo.com/?q=python+negative+index

1 Like

E.g. we have a general list x = [a, b, c, d,]. Negative indexes are the other way to indicate the position of an element within the list. In this case d has index -1, c -2 and so on. Are used depending on your need. For instance, if you have to write the list in the opposite order you can use the negative index:
x = [a, b, c, d]
print (x[: : -1)
I’m sorry but this is all I know, I’m new in programming, in fact I’m here to ask some questions to the forum’s members and casually I saw your question. Have a nice day form Italy