map does a delayed execution, so when you cast the result to a list, the map is executed, which amounts in computing sum(1)
, sum(2)
, sum(-3)
and sum(4)
Any of those will fail because sum takes something like a list (an iterable object) in input. You pass integers which are not iterable, hence the error message.
As suggested in the comments, you want to do a simple sum(x)
.
1
solved Printing the result of a map object in python that is not convertible to list