[Tutor] Help with a Dictionary

spir denis.spir at free.fr
Fri Jan 8 11:57:10 CET 2010


Garry Bettle dixit:

[...series of data with same format...]
> 2010-01-07 1437 Crayfd H3 380m
> ... etc.
> 
> The above are RaceDate + RaceTime + Fixture + RaceDetails, and are
> output in RaceTime order.
> 
> What I'd like to do, is output a transposed-like summary of just the
> Fixture + RaceTime.
> 
> i.e.
> 
> Sund   1103 1119 1134 1148 1204 1218 1232 1247 1304 1319 1333 1351
> Sheff   1111 1128 1142 1157 1212 1227 1242 1258 1312 1327 1344 1403
> Romfd 1408 1427 ...
> Crayfd 1418 1437 ...
> 
> Do I need to use a Dictionary?

The main difference in that case is order keeping. If you don't mind about it, which seems highly probable in your case, then a dict with key=Fixture, value=[lits of RaceTime] does the job. Else, Fixture order makes sense, you can use a list of tuples of the form (Fixture, [lits of RaceTime]).
For output, just " ".join() together RaceTime's when needed.

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/


More information about the Tutor mailing list