Skip to content

Commit ea2a6ea

Browse files
authored
Correct error message assignment in merge_sorted_arrays
Fix variable assignment for error message in merge_sorted_arrays function.
1 parent 743becc commit ea2a6ea

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎data_structures/arrays/merge_sorted.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,23 @@ def merge_sorted_arrays(nums1: list[int], nums2: list[int]) -> list[int]:
2727
2828
>>> merge_sorted_arrays([-5, -3, -1], [-2, -2])
2929
[-5, -3, -2, -2, -1]
30+
3031
>>> merge_sorted_arrays(range(5), range(5))
3132
[0, 0, 1, 1, 2, 2, 3, 3, 4, 4]
33+
3234
>>> merge_sorted_arrays([1, -1], [])
3335
Traceback (most recent call last):
3436
...
3537
ValueError: nums = [1, -1] is not sorted
38+
3639
>>> merge_sorted_arrays([], [1, -1])
3740
Traceback (most recent call last):
3841
...
3942
ValueError: nums = [1, -1] is not sorted
4043
"""
4144
for nums in (nums1, nums2):
4245
if list(nums1) != sorted(nums1):
43-
msg f"{nums1 = } is not sorted"
46+
msg = f"{nums1 = } is not sorted"
4447
raise ValueError(msg)
4548
# If one array is empty, simply return the other.
4649
if not nums1:

0 commit comments

Comments
 (0)