Multiple choice technology programming languages

x=[1,2,3,4,5] print x[-1]

  1. error

  2. 5

  3. garbage number

  4. 3

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Python, negative indexing access elements from the end of the list. The index -1 retrieves the last element, which is 5. It does not produce an error or return a garbage value.