What is the output of the following Python code snippet?
a = [1, 2, 3]
a.remove(2)
print(a)
a.remove(2)
print(a)
Correct answer
A. [1, 3]
5 views
A. [1, 3]
5 views
remove() deletes the first occurrence of the given value.
Asked in: Python Interview Lists
https://docs.python.org/3/tutorial/datastructures.htmlNot sure why the answer is A? Ask here and get an explanation.