I have a dictionary dict2 which I want to iter through and remove all entries that contain certain ID numbers in idlist. dict2[x] is a li
dict2
idlist
dict2[x]
Try a cleaner version perhaps?
for k in dict2.keys(): dict2[k] = [x for x in dict2[k] if x[1] not in idlist] if not dict2[k]: del dict2[k]