On start I have 2 lists and 1 list that says in what order I should merge those two lists. For example I have first list equal to [a, b, c] and second list equa
[a, b, c]
How about this,
list1 = ['a', 'b', 'c'] list2 = ['d', 'e'] options = [0,1,0,0,1] list1_iterator = iter(list1) list2_iterator = iter(list2) new_list = [next(list2_iterator) if option else next(list1_iterator) for option in options] print(new_list) # Output ['a', 'd', 'b', 'c', 'e']