I am trying to delete a dictionary from a list of dictionaries, but unable to achieve it. Here's what I've tried so far:
x = set()
for row in comment_data['data']:
x.add(row['RUNID'])
for row in data['data']:
if row['ID'] not in x:
del row
Here data['data'] is a list of dictionaries. x is a set of numbers, I fetch from comment_data. I want to delete the dictionary if row['id'] is not in x. How do I acieve this? Where am I going wrong? I tried the answers given on this link, but none of them seem to work for me. Any help is appreciated!