Skip to content

Commit 3e0deb7

Browse files
authored
Improve error handling and format examples
Refactor error message handling and update example array format.
1 parent 33ffba8 commit 3e0deb7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

data_structures/arrays/dutch_national_flag_sort.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,21 @@ def dutch_flag_sort(arr: list[int]) -> None:
8484
arr[mid], arr[high] = arr[high], arr[mid]
8585
high -= 1
8686
else:
87-
raise ValueError(f"Array contains invalid value: {value}")
87+
msg = f"Array contains invalid value: {value}"
88+
raise ValueError(msg)
8889

8990

9091
if __name__ == "__main__":
9192
examples = [
92-
([2, 0, 2, 1, 1, 0],),
93-
([2, 0, 1],),
94-
([],),
95-
([1],),
96-
([0, 0, 0],),
97-
([2, 2, 2],),
98-
([1, 1, 1],),
99-
([0, 1, 2, 0, 1, 2],),
100-
([2, 1, 0, 2, 1, 0],),
93+
[2, 0, 2, 1, 1, 0],
94+
[2, 0, 1],
95+
[],
96+
[1],
97+
[0, 0, 0],
98+
[2, 2, 2],
99+
[1, 1, 1],
100+
[0, 1, 2, 0, 1, 2],
101+
[2, 1, 0, 2, 1, 0],
101102
]
102103

103104
for test_arr in examples:

0 commit comments

Comments
 (0)