""" another implementation of an indexed array """ def new_indexed_array(n): """ Return a new Indexed Array """ return { '_size_': n } def _index_is_valid(array, index): assert type(index) == type(1) assert 0 <= index < array['_size_'] def put(array, index, value): """ Assign a value to the array at index """ _index_is_valid(array, index) array[index] = value def get(array, index): _index_is_valid(array, index) return array[index] array = new_indexed_array(4) put(array, 0, 20) put(array, 1, 10) print("The 0'th element of the array is ", get(array, 0)) print("The array is ", array)