I just switched from Python 2 to 3, but this code does not work. What is the problem, please advise.
a = [1, 7, 2, 5, 4, 8]
map(lambda x: x + 2, a)
I expect [3, 9, 4, 7, 6, 10]
I just switched from Python 2 to 3, but this code does not work. What is the problem, please advise.
a = [1, 7, 2, 5, 4, 8]
map(lambda x: x + 2, a)
I expect [3, 9, 4, 7, 6, 10]
Try
a = [1, 7, 2, 5, 4, 8]
list(map(lambda x: x + 2, a))