def best_match(supported, header):
    """Takes a list of supported mime-types and finds the best match for all the media-
    ranges listed in header. The value of header must be a string that conforms to the
    format of the HTTP Accept: header. The value of 'supported' is a list of mime-types.

    >>> best_match(['application/xbel+xml', 'text/xml'], 'text/*;q=0.5,*/*; q=0.1')
    'text/xml'

    """
    parsed_header = [parse_media_range(r) for r in header.split(",")]
    weighted_matches = [
        (fitness_and_quality_parsed(mime_type, parsed_header), mime_type)
        for mime_type in supported
    ]
    weighted_matches.sort()
    return weighted_matches[-1][0][1] and weighted_matches[-1][1] or ''
Takes a list of supported mime-types and finds the best match for all the media-
    ranges listed in header. The value of header must be a string that conforms to the
    format of the HTTP Accept: header. The value of 'supported' is a list of mime-types.

    >>> best_match(['application/xbel+xml', 'text/xml'], 'text/*;q=0.5,*/*; q=0.1')
    'text/xml'