def _code_in_list(code, codelist):
    """Tells if `code` is contained in `codelist`

    Examples:
        - 401 is not contained in ['3xx', '404', '5xx']
        - 404 is contained in ['3xx', '404', '5xx']
        - 503 is contained in ['3xx', '404', '5xx']
    """

    # status codes to exclude
    exact_codes = [code for code in codelist if 'x' not in code]
    
    if str(code) in exact_codes:
        return True

    # classes of status code to exclude
    class_codes = [code[0] for code in codelist if 'x' in code]

    if str(code)[0] in class_codes:
        return True

    return False