Answer the question
In order to leave comments, you need to log in
What is the correct way to compare two dictionaries?
Good day! I have two dictionaries of this kind
old_dict = {'Anton':'454.44', 'Sergey':'345.65','Petr':'7634.88'}
new_dict = {'Anton':'1123.20', 'Sergey':'85.34','Petr':'677.09'}
Answer the question
In order to leave comments, you need to log in
old_dict = {'Anton':454.44, 'Sergey':345.65,'Petr':7634.88}
new_dict = {'Anton':1123.20, 'Sergey':85.34,'Petr':677.09}
items = {k: new_dict[k] for k in new_dict if k in old_dict and new_dict[k] > old_dict[k]}
print(items)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question