I have 2 python lists:
>>> a_list = [1, 2, 3]
>>> b_list = ["a", "b"]
I want to interleave these two lists together into c_list
such that c_list
looks likes this:
[1, "a", 2, "b", 3]
How best to do it??
I have 2 python lists:
>>> a_list = [1, 2, 3]
>>> b_list = ["a", "b"]
I want to interleave these two lists together into c_list
such that c_list
looks likes this:
[1, "a", 2, "b", 3]
How best to do it??
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)