def two_pair(ranks):
  """If there are two pair, return the two ranks as a
  tuple: (highest, lowest); otherwise return None."""

  pairs = set()

  for i in range(len(ranks) - 1):
    if ranks[i] == ranks[i + 1]:
      pairs.add(ranks[i])

  if len(pairs) == 2:
    return tuple(pairs)