def getindex(arr, val, default=-1):
    """Like list.index but allows us to specify a fallback value if the value
    isn't present in the list, kind of like getattr.

    Parameters
    ----------
    arr: list
        The list to search in.
    val: any
        The item to search for.
    default: any
        Value to return if val is not in arr.
    """
    return arr.index(val) if val in arr else default