def find_last_index(l, x):
    """Returns the last index of element x within the list l"""
    for idx in reversed(range(len(l))):
        if l[idx] == x:
            return idx
    raise ValueError("'{}' is not in list".format(x))