Tricky Dictionary Question from newbie

Markus Weihs mweihs at gmx.at
Mon Jul 11 20:15:45 CEST 2005


Hi!


 Dict = {'rt': 'repeated', 'sr':'repeated', 'gf':'not repeated'} 
 NewDic = {}

 for k,v in Dict.items():
     NewDic.setdefault(v, []).append(k)


Regards, mawe






More information about the Python-list mailing list