Below is my dictionary
myd = [
{
'name': 'Abc',
'id': '101',
'status': 'Success',
'lastModifiedDate': '2022-02-14 12:25:32:013302' },
{
'name': 'Abc',
'id': '101',
'status': 'Failed',
'lastModifiedDate': '2022-02-21 12:25:32:013302' },
{
'name': 'def',
'id': '102',
'status': 'Failed',
'lastModifiedDate': '2022-02-14 12:25:32:013302' },
{
'name': 'ghi',
'id': '103',
'status': 'Success',
'lastModifiedDate': '2022-02-14 12:25:32:013302' },
{
'name': 'ijk',
'id': '110',
'status': 'Failed',
'lastModifiedDate': '2022-02-14 12:25:32:013302' },
{
'name': 'ijk',
'id': '110',
'status': 'Failed',
'lastModifiedDate': '2022-02-14 12:25:32:013302' }
]
- I need to extract dictionary status is 'Failed' only
- If status is 'Success' for
idwhich status is 'Failed' then that dictionaries has to delete from list - Only Failed has to do add in the dictionary
- If both id's are failed then it can add that dictionary
Expected out
myd = [
{
'name': 'def',
'id': '102',
'status': 'Failed',
'lastModifiedDate': '2022-02-14 12:25:32:013302' },
{
'name': 'ijk',
'id': '110',
'status': 'Failed',
'lastModifiedDate': '2022-02-14 12:25:32:013302' }
]
code is below
#Remove duplicates
new = [dict(t) for t in {tuple(d.items()) for d in myd}]
for i in new:
if i['id] ==