def convert(txt):
    """
    Convert numeric elements to float or complex if possible.

    success, value = convert(txt)

    If txt can be converted into a number, return success = True and the
    converted value in value. Otherwise return success = False, and value
    contains the input argument.
    """
    try:
        res = float(txt)
        return True, res
    except:
        pass
    try:
        res = complex(txt)
        return True, res
    except:
        return False, txt