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()

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to