What's the best method to parse through a dictionary to find matching entries when compared to another dictionary? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the best method to parse through a dictionary to find matching entries when compared to another dictionary?

Ex: Dictionary_1 compared to Dictionary_2 = Output (unmatched entries) I'm working on a script to read pcap files and compare the output (via MAC address) to ARP tables.

25th Feb 2017, 1:14 AM
Stephen B Summers
Stephen B Summers - avatar
1 Answer
+ 2
Do you mean such code? dict_a = { 'key_a':'value_a', 'key_b':'value_b', 'key_d':'value_d', } dict_b = { 'key_a':'value_a', 'key_c':'value_c', 'key_d':'value_D', # unmatch } unmatch = [key for key in dict_a if key in dict_b and dict_a[key] != dict_b[key]] print(unmatch) # key_d
27th Feb 2017, 12:25 AM
Twelfty
Twelfty - avatar