l1 = [11, 2, 3]
l2 = [5, 3]
def _map(l1, l2):
l1_length = len(l1)
l2_length = len(l2)
min_lengt = min(l1_length, l2_length)
for x in range(min_lengt):
yield l1[x] + l2[x]
if l1_length < l2_length:
temp = l2[min_lengt:]
for t in temp:
yield t
if l2_length < l1_length:
temp = l1[min_lengt:]
for t in temp:
yield t
ret = _map(l1, l2)
print(list(ret))
python中如何按照长的相加两个列表
猜你喜欢
转载自blog.csdn.net/weixin_42289273/article/details/115077331
今日推荐
周排行