Parse list only one time instead of many

35 Views Asked by At

I have this function that parse 4 times the same list :

def function (a_list):
      A = sum([i[1] + i[2] for i in a_list]) 
      B = sum([(i[1] + i[2])*i[3] for i in a_list]) 
      C = sum([i[3] for i in a_list])
      D = list(set([i[0] for i in a_list]))
      return A+B+C+D

Could I do it easily parsing only one time? Thanks!

SL

0

There are 0 best solutions below