Skip to content

Commit 8a5b1ab

Browse files
Deekshaeshacclauss
authored andcommitted
finding max (#1488)
* Update find_max.py * Update find_max.py * Format with psf/black and add doctests
1 parent 39c40e7 commit 8a5b1ab

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

maths/find_max.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33

44
def find_max(nums):
5+
"""
6+
>>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]):
7+
... find_max(nums) == max(nums)
8+
True
9+
True
10+
True
11+
True
12+
"""
513
max = nums[0]
614
for x in nums:
715
if x > max:
816
max = x
9-
print(max)
17+
return max
1018

1119

1220
def main():
13-
find_max([2, 4, 9, 7, 19, 94, 5])
21+
print(find_max([2, 4, 9, 7, 19, 94, 5])) # 94
1422

1523

1624
if __name__ == "__main__":

0 commit comments

Comments
 (0)