[Tutor] Calculate hours

Alan Gauld alan.gauld at btinternet.com
Thu Jan 24 00:13:53 CET 2013


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.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list