import math


def _try_numeric(string):
  """Attempt to convert a string to an int then a float.


  Args:
    string: String to convert

  Returns:
    Attempts, in order, to return an integer, a float, and finally the original
    string.
  """
  try:
    float_val = float(string)
    if math.floor(float_val) == float_val:
      return int(float_val)
    return float_val
  except ValueError:
    return string