sonichuang 发表于 2018-6-2 23:09:09

关于map 或者 filter 两个变量的可迭代范围

下面的代码中怎么同时定义x和y的范围?

>>> list(map(lambda x, y: x + y, range(100)))
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: <lambda>() missing 1 required positional argument: 'y'

第四时空 发表于 2018-6-2 23:56:52

list(map(lambda x, y: x + y, range(1, 11), range(11, 21)))
页: [1]
查看完整版本: 关于map 或者 filter 两个变量的可迭代范围