πŸ“Š Python
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
πŸ’¬ Discuss
βœ… Correct Answer: (C) 3

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

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

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
51
Total Visits
πŸ“½οΈ
7 mo ago
Published
πŸŽ–οΈ
Ankit Singh
Publisher
πŸ“ˆ
81%
Success Rate