a = list of number with length k
b = list of number with length k
如何逐个位置获取a和b中较小值的列表c?
Example:
a = [0.6, 0.8, 0.4]
b = [0.4, 1.0, 0.5]
c = [0.4, 0.8, 0.4]
请您参考如下方法:
您可以使用 zip()像这样:
c = [min(*item) for item in zip(a, b)]
输出:
>>> a = [0.6, 0.8, 0.4]
>>> b = [0.4, 1.0, 0.5]
>>>
>>> c = [min(*item) for item in zip(a, b)]
>>> c
[0.4, 0.8, 0.4]
