Dear Python people,
im a newbie to python and here...so hello! Im trying to iterate through values in a dictionary so i can find the closest value and then extract the key for that value....what ive done so far: def pcloop(dictionary, exvalue): z = dictionary.itervalues() y = z - exvalue v = (y*y)**1/2 if v < 0.001: u = dictionary.get[z] return u ive been working off a couple of books and this is the best i can get it in short time. I was trying to define a function (its my first!) so that i could apply to several 'dictionary's and 'exvalue's. The best ive been able to come up with is iterating over the dictionary values, subtracting the exvalue, squaring then root squaring to render positive and applying an error (0.001) which is not the ideal solution i want. Is there any easy way to iterate through dictionary values and return the key for the minimum. Or can someone tell me where im going wrong with this def & loop. regards all Ali -- http://mail.python.org/mailman/listinfo/python-list