Skip to content

Latest commit

 

History

History
11 lines (11 loc) · 387 Bytes

File metadata and controls

11 lines (11 loc) · 387 Bytes

Indexing

Unlike most programming languages, Python supports negative indexing. Negative indexing starts from the back of the array.

xs = range(10)
print(xs[-1]) # -> 9
print(xs[-10]) # -> 0

This is not exactly modular indexing. The only valid indices i for an arbitrary array xs are -len(xs) ≤ i < len(xs).

Next

slicing mutations