I am using map
to process a list in Python3.6:
def calc(num):
if num > 5:
return None
return num * 2
r = map(lambda num: clac(num), range(1, 10))
print(list(r))
# => [2, 4, 6, 8, 10, None, None, None, None]
The result I expect is: [2, 4, 6, 8, 10]
.
Of course, I can use filter
to handle map
result. But is there a way for map
to return directly to the result I want?