我有两个列表,并希望按每个元素将它们组合为一个列表:
List1 = ['s', 'd', 'c']
List2 = ['a', 'b', 'h']
我想要什么:
List = ['sa', 'db', 'ch']
答案 0 :(得分:2)
尝试一下:
b.Descuento_Cliente
答案 1 :(得分:0)
List comprehension和zip是您的救星。试试:
[''.join(i) for i in zip(List1, List2)]
或者您可以这样做:
[i + j for i, j in zip(List1, List2)]
答案 2 :(得分:-1)
List1 = ['s', 'd', 'c']
List2 = ['a', 'b', 'h']
ls =[]
for i in range(len(List1)):
ls.append(List1[i]+List2[i])
print(ls)