Skip to content

Commit bf62aff

Browse files
authored
Enhance docstring for reverse_array function
Updated docstring to clarify that the function returns the reversed list.
1 parent 81fd398 commit bf62aff

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎data_structures/arrays/reverse_array.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
In-place array reversal.
2+
In-place array reversal that also returns the list to the caller.
33
This algorithm reverses the elements of a list without using extra space.
44
"""
55

@@ -34,6 +34,12 @@ def reverse_array(arr: list[Any]) -> list[Any]:
3434
[1]
3535
>>> reverse_array([])
3636
[]
37+
>>> reverse_array(list(range(5)))
38+
[0, 1, 2, 3, 4]
39+
>>> reverse_array(tuple(range(5)))
40+
[0, 1, 2, 3, 4]
41+
>>> reverse_array(range(5))
42+
[0, 1, 2, 3, 4]
3743
"""
3844
left = 0
3945
right = len(arr) - 1

0 commit comments

Comments
 (0)