title: Add third element in list of tuple having three elements each , if first two elements are Identical
body: <p>How can I add third element to the tuple, if first two elements are same?.
  Here in list we have three tuples having first two identical elements <code>6220</code> and <code>586</code> . 
  So that we need to create a new single tuple like this <code>[(6220,586,(5+5+5))]</code>.</p>
  
  <pre><code>list = [(6220, 586, 5), (7032, 621, 0), (7030, 589, 0), (7032, 621, 0), (6220, 586, 5), (7030, 589, 0), (7032, 621, 0), (6220, 586, 5)]
  </code></pre>
  
  <p>Expected Output : </p>
  
  <p><code>[(6220, 586, 15),(7032, 621, 0),(7030, 589, 0)]</code></p>
  
  <p>so far i have come up with the following : </p>
  
  <pre><code>a_b=[]
  for x in lst:
      for y in lst:
          if len(a_b) == 0:
              a_b.append((x[0],x[1],x[2]))
          if x[0]==y[0] and x[1]==y[1]:
                  if (x[0],x[1],x[2]+y[2]) not in a_b:
                      t=(x[0],x[1],x[2]+y[2])
                      a_b.append(t)
  </code></pre>