def check(value, condition, string=''):
    """
    Verify that the condition is true and return the value.

    Useful for conditional assignments, eg:
        xs = [x]*n_elements if not isinstance(x, (list, tuple)) else check(x, len(x)==n_elements)

    :param value:
    :param condition:
    :param string:
    :return:
    """
    assert condition, string
    return value
