A

Admin • 833.24K Points
Coach

Q. What is the output of the following code?

Code:
x = [1, 2, 3]
print(x[-1])
  • (A) 1
  • (B) 2
  • (C) 3
  • (D) Error
  • Correct Answer - Option(C)
  • Views: 37
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

Negative indexing starts from the end. x[-1] refers to the last element, which is 3.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.