def ap(docs, n=10):
    """Average Precision"""
    precision_values = [
        len([
            doc
            for doc in docs[:idx]
            if doc["relevant"] == "true"
        ]) / idx
        for idx in range(1, n + 1)
    ]
    return sum(precision_values) / len(precision_values)