I have this dictionary in which (key1, key2): value
dict = {('1', '4'): 'A', ('3', '8'): 'B', ('4', '7'): 'C',
('8', '9'): 'D', ('4', '2'): 'E', ('2', '0'): 'F', ('3', '9'):
'G', ('7', '7'): 'H', ('8', '6'): 'I', ('5', '3'): 'J',
('6', '1'): 'K'}
key1 = input('enter value of key1: ')
key2 = input('enter value of key2: ')
If I enter a key pair1, key2 and the pair does not exist, is there a way that I can scroll this dictionary and pass a mathematical function, that is, find the average value for each key pair and type one has the largest average value?
Edit: this dictionary was actually obtained from a text file, so it should be the first in the line, and I need to convert it to int, but I don't know how to do it.
source
share