def get_or_put(list_, value):
    """Inserts value in list_ if not preset, returns the index of value."""
    try:
        return list_.index(value)
    except ValueError:
        list_.append(value)
        return len(list_) - 1