I have two lists J_new and C. For every True element of C, I want to remove the corresponding element in J_new. For instance, since C[0]=True, I want to remove J_new[0]=1. I present the current and expected outputs.
J_new = [1, 9, 15]
C=[True, True, False]
for i in range(0,len(C)):
if(C[i]=='True'):
C[i]=[]
J_new=J_new[C[i]]
print(J_new)
The current output is
[1, 9, 15]
The expected output is
[15]
>Solution :
When accessing parallel lists, always think "zip"!
>>> J_new = [1, 9, 15]
>>> C = [True, True, False]
>>>
>>> [j for j, c in zip(J_new, C) if not c]
[15]