AttributeError

MRAB python at mrabarnett.plus.com
Thu Aug 13 00:35:57 CEST 2015


On 2015-08-12 22:16, Denis McMahon wrote:
[snip]

> c = [0 for i in range(24)]
> f = open(filename,'r')
> for l in f:
>      h = int(l.strip().split()[X].split(':')[Y])
>      c[h] = c[h] + 1
> f.close()
> for i in range(24):
>      print '{:02d} {}'.format(i, c[i])
>
There's no need to strip whitespace just before splitting on it.

This:

     l.strip().split()

can be shortened to this:

     l.split()



More information about the Python-list mailing list