less than 1 minute read

Suppose:

list = [2, 33, 222, 14, 25]
print(list[-1])

Options:

A) Error

B) None

C) 25

D) 2

Answer: C) 25.

The index -1 corresponds to the last index in the list.

Additional information

What is a negative index?

This means that the index value of -1 gives the last element, and -2 gives the second last element of an list. The negative indexing starts from where the list ends.

This means that the last element of the array is the first element in the negative indexing which is -1.

References

Negative index

Example