What is the output of print(list(map(lambda x: x * x, [1, 2, 3]))) in Python?
print(list(map(lambda x: x * x, [1, 2, 3])))
Correct answer
A. [1, 4, 9]
6 views
A. [1, 4, 9]
6 views
map() applies a function to every item; list() consumes the iterator.
Asked in: Python Interview Functions
https://docs.python.org/3/tutorial/controlflow.html#defining-functionsNot sure why the answer is A? Ask here and get an explanation.