How do I compare two lists of dict? The result should be the odd ones out from the list of dict B.
Example:
ldA = [{'user':"nameA", 'a':7.6, 'b':100.0, 'c':45.5, 'd':48.9},
{'user':"nameB", 'a':46.7, 'b':67.3, 'c':0.0, 'd':5.5}]
ldB =[{'user':"nameA", 'a':7.6, 'b':99.9, 'c':45.5, 'd':43.7},
{'user':"nameB", 'a':67.7, 'b':67.3, 'c':1.1, 'd':5.5},
{'user':"nameC", 'a':89.9, 'b':77.3, 'c':2.2, 'd':6.5}]
Here I want to compare ldA with ldB. It should print the below output.
ldB -> {user:"nameA", b:99.9, d:43.7}
ldB -> {user:"nameB", a:67.7, c:1.1 }
ldb -> {user:"nameC", a:89.9, b:77.3, c:2.2, d:6.5}
I have gone through the below link, but there it return onlys the name, but I want name and value like above.
List of Dicts comparision to match between lists and detect value changes in Python
For a general solution, consider the following. It will properly diff, even if the users are out of order in the lists.
Then, you can check the solution: