How do I convert string into integers in this dictionary then loop through it without getting errors like invalid literal for int() with base 10 🙁
mydict = {('6.0', '1.0'): '345.2', ('3.0', '9.0'): '632.7',
('2.0', '3.0'): '222.4', ('1.0', '4.0'): '672.1', ('8.0', '6.0'): '822.6',
('3.0', '8.0'): '225.5', ('7.0', '7.0'): '534.0', ('4.0', '7.0'): '599.3',
('8.0', '9.0'): '273.5', ('5.0', '3.0'): '822.5', ('4.0', '2.0'): '326.6'}
in which (key1, key2): value
I would also like to loop through this dictionary, and calculate using this formula…
((key1 * 360 / key2 * 180) + value)
for each key pair. Then, I would print out the 3 largest value resulted from the calculation. Is this possible?
You can do the following:
That will produce something like :
To get the 3 largest:
Hope that helps.