What is the output of print(sum(i for i in [1, 2, 3])) in Python?
print(sum(i for i in [1, 2, 3]))
Correct answer
A. 6
5 views
A. 6
5 views
A generator expression can be passed directly to sum().
Asked in: Python Interview Advanced
https://docs.python.org/3/library/index.htmlNot sure why the answer is A? Ask here and get an explanation.