I wanna remove a dictionary from a nested dictionary and I don't know how. From this dictionary:
dict = {
'user': [
{
'firstName': 'john',
'lastName': 'doe',
'movieList': []
},
{
'firstName': 'sarah',
'lastName': 'doe',
'movieList': []
},
{
'firstName': 'john',
'lastName': 'smith',
'movieList': []
},
{
'firstName': 'sarah',
'lastName': 'smith',
'movieList': []
}
], 'movie': []
}
I want to remove:
{
'firstName': 'john',
'lastName': 'doe',
'movieList': []
}
which has the index 0 I tried using delete but i get this error:
dict['user'][userId] TypeError: list indices must be integers or slices, not str
First, I wouldn't name the dict "dict", use "d" or something else.
dict['user'].pop(0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With