def check_var(variable, allowed_range, default=None, logger=None):
    """Check if a given variable (string, number etc.) is "allowed."""
    if variable not in allowed_range:
        logger.warning(str(variable) + ' is not a valid choice of ' + str(
            list(allowed_range.keys())) +
            '. Instead, the default value was used: ' + default)
        variable = default
    return variable
