In the List of tuples, add the 2nd element if the first and last element matches with the other tuples.
    p =[(u'basic', 7698, '01-2017'),
    (u'basic', 7685, '01-2017'),
    (u'Gross', 4875.0, u'01-2017'),
    (u'Gross', 4875.0, u'01-2017')]
And the output should be like
    [(u'basic',15383,'01-2017'),(u'Gross', 9750.0, u'01-2017')]
I'm trying to do this way
   o=[]        
   for i in p:
     if i[2] not in o:
        o.append(i[2])
     if i[0] not in o:
        o.append(i[0])
   count +=i[1]
   o.append(count)
my o/p:
   ['01-2017', 'basic', u'Gross', 53050.0, 4875.0]