Q:

Can't access Second Item of Python object

I have a dictionary of items, where the list is formatted to be 
{(x,y): z, (x,y):z...} where x and y are coordinates and z is a probability. I need to perform operations using the probability. How can I access those?
I tried things like 
    for item in lst:
        print item[1]

However, that only returned the y coordinate. Attempting to print item[2] returned the error "Need more than 2 values to unpack"

A:

As you are using a dictionary, python can retrieve both names and values individually. For example for:
>>> a = {(1,2): 0.5, (2,3): 0.4}
>>> a.keys()
>>> [(1, 2), (2, 3)]

>>> a.values()
>>> [0.5, 0.4]

Therefore for you to perform calculations on the probabilities you need to do:
for item in a.values():
    print item

each item will output the values of your dictionary in sequence.

