On Tue, 11 Aug 2015 22:03:05 -0700, Ltc Hotspot wrote:

> Question: What sorted function should I write to produce the desired
> output, below:

Me, I'd start by declaring a dictionary to hold the data:

counts = { "{:02d}".format(h):0 for h in range(24) }

Then I'd parse the strings in the log file(s), incrementing counts[x] 
where x is the hour field of the timestamp.

Then I'd create a list of tuples:

ncounts = [(k,v) for k,v in counts.items()]

sort it by the hour field:

ncounts.sort(key = lambda x: x[0])

and print it:

for x in ncounts:
    print x[0], x1

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to