I have two lists of length n and n+1:
[a_1, a_2, ..., a_n]
[b_1, b_2, ..., b_(n+1)]
I want a function giving as a result a list with alternate elements from the two, that is
[b_1, a_1, ..., b_n, a_n, b_(n+1)]
The following works, but does not look smart:
def list_mixing(list_long,list_short):
list_res = []
for i in range(len(list_short)):
list_res.extend([list_long[i], list_short[i]])
list_res.append(list_long[-1])
return list_res
Can anyone suggest a more pythonic way of doing this? Thanks!