find minimum associated values

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


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

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

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

Cheers,
Alan Isaac



More information about the Python-list mailing list