I have two lists like below.i am getting this from database
EmpID = Assign.objects.select_related().filter(pName=selProject).filter()
.order_by('laEmpNum').values_list('laEmpNum', flat=True)
TotDur = Assign.objects.select_related().filter(pName=selProject).order_by('laEmpNum')
.values_list('duration', flat=True)
EmpID = [u'1046', u'1046', u'1046', u'8008', u'8008', u'8011']
TotDur = [0.0, 2.0, 2.5, 0.0, 2.7, 1.2]
If EmpIDs are same then corresponding values in TotDur should collect and add(sum).
ResOne = 0.0 + 2.0 + 2.5 i.e 4.5
ResTwo = 0.0+2.7 i.e 2.7
ResThr = 1.2 i.e 1.2
How to do this in Python.
If the elements are in order as you have shown in your example, you can use itertools.groupby
infact you don’t need to create two separate list and zip it later