Implementing file reading in C/Python
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Jan 9 04:45:50 EST 2009
On Fri, 09 Jan 2009 04:04:41 +0100, Johannes Bauer wrote:
> datamap = { }
> for i in range(len(data)):
> datamap[ord(data[i])] = datamap.get(data[i], 0) + 1
Here is an error by the way: You call `ord()` just on the left side of
the ``=``, so all keys in the dictionary are mapped to ones after the
loop which gives a pretty boring PGM. :-)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list