def ctype(v, t):
    """Convert "v" to type "t"

    >>> ctype('10', int)
    10
    >>> ctype('10', list)
    ['1', '0']
    >>> ctype(10, list)
    10
    >>> ctype('10a', float)
    '10a'

    :param tp.Any v:
    :param tp.TypeVar t:
    :return tp.Any:
    """
    try:
        return t(v) or v
    except (ValueError, TypeError):
        return v