I would like to move a value inside one nested list into another empty nested list. More specifically, I'd like copy the value if and only if the nested list with the same index is empty.
If I have:
L = [, [2.718], [3.14], ] M = [, , , ]
I want to return:
M = [, , , ]
I know that I can do each one by hand by doing:
but I'd like to do it with a for loop for lists that are much bigger.
I've tried doing
for i in M: if bool(i)==False: M[i].append(L[i])
But this gives me "TypeError: list indices must be integers, not list" for the last line. Any ideas on how to fix the for loop?