I have the following situation:
data = {'key1' : 'value1',
'key2': [
{'subkey1': 'subvalue1',
'subkey2': 'subvalue2'},
{other dictionaries}
...
]
}
I have the exact dictionary:
{'subkey1': 'subvalue1', 'subkey2': 'subvalue2'}
stored in a variable. I would like to remove it from the data dict. How could I do this?
Answer
lists have a remove
method, so if you know the key
data['key2'].remove({'subkey1': 'subvalue1', 'subkey2': 'subvalue2'})
No comments:
Post a Comment