find minimum associated values

Alan Isaac aisaac at
Sat Jan 26 00:41:08 CET 2008

bearophileHUGS at wrote:
> I'd use the first solution.

It can be speeded up a bit with
a try/except:

for k,v in kv:
        if d[k] > v:
            d[k] = v
    except KeyError:
        d[k] = v

Alan Isaac

More information about the Python-list mailing list