All,
o1 = ["a","b","c","d","e","f","g","h"]
index = [3,4]
value = ["c","d"]
[x for x in o1 if x not in value]
[x for x in o1 if x not in [o1[y] for y in index]]
any simpler solution for above lc?
Thanks
All,
o1 = ["a","b","c","d","e","f","g","h"]
index = [3,4]
value = ["c","d"]
[x for x in o1 if x not in value]
[x for x in o1 if x not in [o1[y] for y in index]]
any simpler solution for above lc?
Thanks
(x for x in o1 if x not in value)
(x for i, x in enumerate( o1 ) if i not in index )
Note that using generator expressions will save you a pass through the list, and using sets instead of lists for index and value will be more efficient.