def index(predicate, seq):
    """
    Returns the index of the element satisfying the given predicate, or None.
    """
    try:
        return next(i for (i, e) in enumerate(seq) if predicate(e))
    except StopIteration:
        return None