If what you present us here is indeed your data structure {(x,y): z, (x,y):z...}
then you should iterate and unpack it in another fashion than you do:
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> l = {(1,2):0.5, (3,4):0.9}
>>> for coordinates, probability in l.items():
... print(coordinates, probability)
...
(1, 2) 0.5
(3, 4) 0.9
See Documentation
If you want a list of tuples, you could transform it easily with
>>> [ (coordinates, probabilities) for coordinates, probabilities in l.items() ]
[((1, 2), 0.5), ((3, 4), 0.9)]
In your version, you unpack the keys of the dictionary, which are a tuple
of an x
and a y
coordinate. print item[1]
references the y
coordinate (python has 0
-based indexing), which is not, what you want.