I have two nested lists (list of lists) and one nested list of True/False (pattern) that I want to use to pick and choose items from two input lists to create a final list.
inputListTrue = [[1,1,1],[2,2,2],[3,3,3]]
inputListFalse = [[a,a,a],[b,b,b],[c,c,c]]
pattern = [[True, False, True],[True, True, True],[False, False, True]]
finalDesiredList = [[1,a,1],[2,2,2],[c,c,3]]
What is the most efficient way to create a definition that would work on any depth of nested lists....[[[],[]],[]]
etc. I was looking for something really flexible unlike my initial thought of just iterating:
for i, j, k in zip(pattern, inputListTrue , inputListFalse ):
for l,m,n in zip(i,j,k):
if l:
finalDesiredList .append(m)
else:
finalDesiredList .append(n)
This is only good for a list of lists and not for list of list of list etc. Ideas?