diff --git a/data_structures/arrays/dynamic_array.py b/data_structures/arrays/dynamic_array.py index ad4bfb4f9..5c758ad37 100644 --- a/data_structures/arrays/dynamic_array.py +++ b/data_structures/arrays/dynamic_array.py @@ -78,6 +78,11 @@ class DynamicArray: if index < 0 or index >= self.size: raise IndexError("index out of range") return self.array[index] + + def __setitem__(self, index: int, value: int) -> None: + if index < 0 or index >= self.size: + raise IndexError("index out of range") + self.array[index] = value def __len__(self) -> int: """