[Tutor] Calculate hours
Mitya Sirenef
msirenef at lightbird.net
Thu Jan 24 00:24:47 CET 2013
On 01/23/2013 06:13 PM, Alan Gauld wrote:
> On 23/01/13 03:08, Mitya Sirenef wrote:
>
>> To make the change you need, use list comprehension to make sums of all
>> rows, sort it (using list sort method); iterate over it using
>> enumerate() and print out "employee N, sum of hours:"
>
> One problem with that approach is that the employees are identified
by their index in the original row so you probably need to maintain a
note of that index. So before sorting you might want to create a tuple
> with the id and the values then sort on the second element. Only
slightly more complex...
>
> hth.
>
Oh, that's right - thanks for catching this. -m
--
Lark's Tongue Guide to Python: http://lightbird.net/larks/
The best author will be the one who is ashamed to become a writer.
Friedrich Nietzsche
More information about the Tutor
mailing list