code: def extract_twin_values(triples, traits, gender=None):
      
      # Construct the pairs of trait values
      traitValuesAbsent = 0
      nanValues = 0
      genderSkipped = 0
      twinValues = []
      for a, b, t in triples:
          if gender is not None and t != gender:
              genderSkipped += 1
              continue
          if not (a in traits and b in traits):
              traitValuesAbsent += 1
              continue
          if np.isnan(traits[a]) or np.isnan(traits[b]):
              nanValues += 1
              continue
          twinValues.append((traits[a], traits[b]))
  
      print("A total of {} pairs extracted ({} absent; {} nan; {} genderSkipped)"\
          .format(len(twinValues), traitValuesAbsent, nanValues, genderSkipped))
      return twinValues
docs: Calculate the heritability of certain traits in triplets.
  
      Parameters
      ==========
      triples: (a, b, "Female/Male") triples. The sample IDs are then used to query
               the traits dictionary.
      traits: sample_id => value dictionary
  
      Returns
      =======
      tuples of size 2, that contain paired trait values of the twins