I have two lists of dictionaries:
list_1 = [
{'total': 18, 'lead_status': '2'},
{'total': 18, 'lead_status': '9'},
{'total': 18, 'lead_status': '8'},
{'total': 16, 'lead_status': '15'},
{'total': 17, 'lead_status': '14'}
]
list_2 = [
{'total': 18, 'lead_status': '2'},
{'total': 22, 'lead_status': '9'},
{'total': 18, 'lead_status': '8'},
{'total': 16, 'lead_status': '15'},
{'total': 17, 'lead_status': '14'}
]
lead_status
always have unique value and the order of dictionary in lists might or might not be same.
I want to check that for each lead_status
the total
value is same or not in both lists
Example
For lead_status : '2'
both the lists have same total
which is 18 then it returns True
For lead_status : '9'
both the lists have different total
which is 18 in list_1
but 22 in list_2
. So it returns False
.
I have tried the answer in this solution: Comparing 2 lists consisting of dictionaries with unique keys in python
Please help to solve this problem. Any help is appreciated.