What will be the output of the following Python program?

numbers = [10, 20, 30, 40]
print(numbers[-1])
                        

Options

  • A. 10
  • B. 20
  • C. 40
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 40

Detailed Explanation

Negative indexing accesses elements from the end of a list. -1 represents the last element.