我有2个python列表:
>>> a_list = [1, 2, 3]
>>> b_list = ["a", "b"]
我想将这两个列表交错到c_list
,以便c_list
看起来像这样:
[1, "a", 2, "b", 3]
如何做到最好?
答案 0 :(得分:0)
result = []
while a_list and b_list:
result.append(a_list.pop(0))
result.append(b_list.pop(0))
result.extend(a_list)
result.extend(b_list)