building a dict

rurpy at yahoo.com rurpy at yahoo.com
Sat Mar 13 18:16:16 CET 2010


On Mar 13, 9:26 am, ru... at yahoo.com wrote:
> That should be:
> d = {}
> for item in m:
      key = item[0];  value = item[1]
>     if key is None or value is None: continue
>     if key not in dict:
>         d[key] = [1, value]
>     else:
>         d[key][0] += 1
>         d[key][1] += value

That's it.  Any other mistakes, you find 'em.




More information about the Python-list mailing list