def int_or_float(x):
    """Return int or float value of x.

    Args:
        x (str): Value to convert.

    Returns:
        int or float:

    Raises:
        ValueError:
    """
    try:
        return int(x)
    except ValueError:
        try:
            return float(x)
        except ValueError:
            raise ValueError('invalid literal for int_or_float(): \'{}\''.format(x))