How to go to the end of an array

arrays, python

Solution

Indexes start from 0.

l = [3, 5, 7]
#    0  1  2

The last item is at index `len(l) - 1`, not `len(l)`.

Also, use

j = x[-1]

since negative indexes count from the end of the list.

Problem

To go the the last value in an array, would you use the code: ``` j = x[len(x)-1] ``` because this seems to be giving me the last but one, so this is really a question of how the len() thing works with arrays.

Original source