finding max (#1488)

* Update find_max.py

* Update find_max.py

* Format with psf/black and add doctests
This commit is contained in:
Deekshaesha 2019-10-28 13:44:53 +05:30 committed by Christian Clauss
parent 39c40e7e40
commit 8a5b1abd0a

View File

@ -2,15 +2,23 @@
def find_max(nums):
"""
>>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]):
... find_max(nums) == max(nums)
True
True
True
True
"""
max = nums[0]
for x in nums:
if x > max:
max = x
print(max)
return max
def main():
find_max([2, 4, 9, 7, 19, 94, 5])
print(find_max([2, 4, 9, 7, 19, 94, 5])) # 94
if __name__ == "__main__":