What is the output of the following Python code snippet?
a = [1, 2, 3]
a.insert(1, 9)
print(a)
a.insert(1, 9)
print(a)
Correct answer
B. [1, 9, 2, 3]
B. [1, 9, 2, 3]
insert(i, x) inserts x before index i.
Asked in: Python Interview Lists
https://docs.python.org/3/tutorial/datastructures.htmlNot sure why the answer is B? Ask here and get an explanation.