You should use list comprehension and zip and instead of deleting elements from a
, instead take elements in a whose b
value is over 15. Example -
a[:] = [i for i,j in zip(a,b) if j >=15]
We are using a[:]
on the left side, so that a
list object gets mutated inplace. (This is different from a = <something>
as the latter simply binds name a
to a new list whereas former mutates the list inplace).
Demo -
>>> a = [1,2,3,4,5,6,7,8,9]
>>>
>>> b = [10,11,12,13,14,15,16,17,18]
>>> a[:] = [i for i,j in zip(a,b) if j >=15]
>>> a
[6, 7, 8, 9]