What is the output of the following Python code snippet?
a = [1, 2, 3]
a.append(4)
print(a)
a.append(4)
print(a)
Correct answer
B. [1, 2, 3, 4]
7 views
B. [1, 2, 3, 4]
7 views
append() adds an item to the end of the list in place.
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.