[Tutor] to process data from several dictionaries

Andrzej Kolinski AKolinski at nriindustries.com
Wed Dec 7 15:51:16 CET 2005


Let's forget for the time being my previous topic (files - strings - 
lists). As a result of (not only) my efforts I arrived to the point that I 
have data I need but I do not know how to process them. Form each (game) 
file a dictionary is created containing player names (key) and the scores 
+ boards played (tuple), ex.:
from file 1 -
{'Chrabalowski': [(21.0, 24)], 'Stankiewicz': [(-28.0, 24)], ... more ...}
from file 2 -
{'Chrabalowski': [(45.0, 25)], 'Orlicka': [(-27.0, 25)], ... more ...}
from file 3 -
{'Chrabalowski': [(-23.0, 25)], 'Stankiewicz': [(20.0, 25)], ... more 
...}, etc.

Eventually I will have 10 files to process. I need help how to calculate a 
final ranking for each player using  individual data. Many names will be 
repeated but there will be some that appear only once or twice. So for 
"Chrabalowski" we'll have:
                                (21.0 + 45.0 - 23.0)/(24 + 25 + 25),
and for "Stankiewicz:
                                (- 28.0 + 20.0)/(24 + 25)

I have no clue how to do it. Maybe dictionaries are not good for that, 
maybe I should be using lists of lists? Please help.

        _/_/      _/     _/
   _/       _/  _/   _/
  _/_/_/_/  _/ _/
 _/      _/  _/   _/
_/     _/  _/      _/

Andrzej Kolinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051207/e2aa2fcf/attachment.html


More information about the Tutor mailing list