input: 
  def find_mode(values):
      """ Find the mode of the given set of values. The mode is the value that 
      appears most frequently in the list. If there are multiple modes, the 
      first one encountered in the list will be returned.
      >>> find_mode([1, 2, 3, 2, 4, 2])
      2
      >>> find_mode([5, 5, 5, 2, 2, 3, 3, 3, 3])
      3
      """
      max_count = 0
      mode = values[0]
      count = {}
      for item in values:
          if item in count:
              count[item] += 1
          else:
              count[item] = 1
          if count[item] > max_count:
              max_count = count[item]
              mode = item
      return mode
  
output:     max_count = 0
      mode = values[0]
      count = {}
      for item in values:
          if item in count:
              count[item] += 1
          else:
              count[item] = 1
          if count[item] > max_count:
              max_count = count[item]
              mode = item
      return mode