What is the output of the following Python code snippet?
a = [1, 2]
a += [3]
print(a)
a += [3]
print(a)
Correct answer
A. [1, 2, 3]
9 views
A. [1, 2, 3]
9 views
Augmented assignment += on a list extends it in place.
Asked in: Python Interview Output Prediction
https://docs.python.org/3/reference/datamodel.htmlNot sure why the answer is A? Ask here and get an explanation.