def to_number(number):
    """
    Converts a string to a int if possible, else a float.

    :param number: The string to convert to a number
    :type number: string

    :return: The converted number
    :rtype: : int or float depending on the format of the string

    """
    try:
        return int(number)
    except ValueError:
        return float(number)