Avatar ·

Iterating key-value pairs in 2 or more dictionaries and writing matches to a new dictionary using *args

📁 dictionary, Advanced Python Topics, Help, Error

There are two dictionaries, need to iterate over key-value pairs in both dictionaries. Compare if there are identical key-value pairs using a for loop and *args parameter. Add the matching key-value pairs to a new dictionary.

operator_one = { 2: 'break',         1: 'pass',         3: 'print',         4: 'yield',         5 :'try' ,         }operator_two = { 1: 'pass',         2:'global',         3: 'yield',