There are two dictionaries, you need to compare the key value in both dictionaries and write the coincidence in the new dictionary.
operator_one = { 1: 'pass', 2: 'break', 3: 'print', 4: 'yield', 5 :'try' , } operator_two = { 1: 'pass', 2:'global', 3: 'yield', 4: 'print', 5: 'try', } def operator_important(operator_one, operator_two): """Поиск одинаковых элементов в словаре и словаре и запись в словарь.""" operator_main = {} for key, values in operator_one.items: if key, values in operator_two.items: operator_main[key] = values return operator_main d = operator_important(operator_one, operator_two)print(d)