def rel_index(elem, lst, default=None):
    """`lst.index(elem) / len(lst)` with fallback."""
    try:
        return lst.index(elem) / len(lst)
    except ValueError:
        if default == None:
            raise
        return default