AI engineering glossary · Python core
What is negative indexing?
Negative indexing: Using negative numbers as positions counted from the end of a sequence, where -1 is the last element, -2 the second last, and so on. It avoids computing the length to reach elements near the end.
Negative indexing: an example
For nums = [10, 20, 30, 40], nums[-1] is 40 and nums[-2] is 30.
Related terms
More Python core terms
Where you learn it
Negative indexing is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.