I want to iterate through this dictionary of dictionary. Ultimately I want to divide up the values from each dict.. e.g., 0.5/0.4, 0.3/0.2, and 0.1/0.1 to find the max, but I haven't reached there yet. Any help with the iteration would be appreciated.
#!/usr/bin/env python2
dict = {('a', 0.5): ('b', 0.4), ('c', 0.3): ("d", 0.2), ('e', 0.1): ('f', 0.1)}
for keys, values in dict:
print "key: %s" % keys
print "values: %f" % values
for keys1, values1 in dict[keys]:
print "key1: %s" % keys1
print "values1: %f" % values1
However I get an error:
key: a
values: 0.500000
Traceback (most recent call last):
File "test.py", line 8, in
for keys1, values1 in dict[keys]: KeyError: 'a'