我有两份清单,比方说:
list1 = ["red", "blue", "yellow"]
list2 = ["frog", "lion", "tiger", "ant", "shrew", "bee"]我想循环这两个列表的级联,但我希望list1的每个值都与list2的每个值连接,然后再转到list1的下一个值。结果是:红蛙、红狮、红虎、红蚁、红萧、红蜂、蓝蛙等。
我想不出我会如何错开循环。
发布于 2019-11-12 10:58:02
listColourAnimal = []
for colour in list1:
for animal in list2:
listColourAnimal.append(colour + ' ' + animal)
print(listColourAnimal)https://stackoverflow.com/questions/58817174
复制相似问题