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