Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
added 13 characters in body
Source Link
T. Sar

This is the mnemonic method I use. It is just an approach of what is happening, but it works.


Don't think of those as indexes. Think of them as offsets on a circular list.

Let's use the list x = [a,b,c,d,e,f,g,h] as an example. Think about a[2]x[2] and a[x[-2]:

enter image description here

You start at offset zero. If you move two steps forward, you're going from a to b (0 to 1), and them from b to c (1 to 2).

If you move two steps backward, you're going from a to h (0 to -1), and then from h to g (-1 to -2)

This is the mnemonic method I use. It is just an approach of what is happening, but it works.


Don't think of those as indexes. Think of them as offsets on a circular list.

Let's use [a,b,c,d,e,f,g,h] as an example. Think about a[2] and a[-2]:

enter image description here

You start at offset zero. If you move two steps forward, you're going from a to b (0 to 1), and them from b to c (1 to 2).

If you move two steps backward, you're going from a to h (0 to -1), and then from h to g (-1 to -2)

This is the mnemonic method I use. It is just an approach of what is happening, but it works.


Don't think of those as indexes. Think of them as offsets on a circular list.

Let's use the list x = [a,b,c,d,e,f,g,h] as an example. Think about x[2] and x[-2]:

enter image description here

You start at offset zero. If you move two steps forward, you're going from a to b (0 to 1), and them from b to c (1 to 2).

If you move two steps backward, you're going from a to h (0 to -1), and then from h to g (-1 to -2)

Source Link
T. Sar

This is the mnemonic method I use. It is just an approach of what is happening, but it works.


Don't think of those as indexes. Think of them as offsets on a circular list.

Let's use [a,b,c,d,e,f,g,h] as an example. Think about a[2] and a[-2]:

enter image description here

You start at offset zero. If you move two steps forward, you're going from a to b (0 to 1), and them from b to c (1 to 2).

If you move two steps backward, you're going from a to h (0 to -1), and then from h to g (-1 to -2)

lang-py