title: Is there a way to iterate through a list of tuples and update the range as you remove tuples?
body: <p>I am currently trying to write code for iterating through a list of tuples and if the names match check who is older and remove the younger one from the list. I am running into an issue where if I remove a tuple, the code still tries to iterate through the original range even though I update the variable l.
  Code:</p>
  <pre><code>dads = [('Jim', '30'), ('Jeff', '45'), ('Jim', '35')]
  l = len(dads)
  for i in range(l):
      for j in range(l):
          if dads[i][0] == dads[j][0]:
              if int(dads[i][1]) &gt; int(dads[j][1]):
                  dads.pop(j)
                  l = len(dads)
                  if j &lt; i:
                      j -= 1
                      i -= 1
  print(dads)
  </code></pre>