def valid_conversion(val, type_to_convert):
    """
    Checking whether it is possible to convert val to the specified type
    :param val: value
    :param type_to_convert: type
    :return: boolean
    """

    if isinstance(type_to_convert, type):
        try:
            type_to_convert(val)
            res = True
        except ValueError:
            res = False

    else:
        raise TypeError
    return res