I'm looking to find the diff between two dictionaries.
[Dict. 1]
{"1":"w"},
{"2":"x"},
{"3":"y"}
[Dict. 2]
{"2":"b"},
{"3":"y"},
{"4":"z"}
I want to find the diff that will transform Dict. 2 into a dictionary that is identical to Dict. 1
I am not allowed to set Dict. 2 equal to Dict. 1.
I can only modify Dict. 2 by using the least number of add/update/remove actions possible. For the above example, my diff should look like.
[Dict. 2] [Diff] [Dict. 2]
{"2":"b"}, add("1","w") {"1":"w"},
{"3":"y"}, + update("2","x") = {"2":"x"},
{"4":"z"} remove("4") {"3":"y"}
Using Python, how can I find the diff for these two dictionaries? My diff needs to contain the least number adds, updates, and removes.