TheAlgorithms-Python/maths/find_max.py
Deekshaesha 8a5b1abd0a finding max (#1488)
* Update find_max.py

* Update find_max.py

* Format with psf/black and add doctests
2019-10-28 09:14:53 +01:00

26 lines
397 B
Python

# NguyenU
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
return max
def main():
print(find_max([2, 4, 9, 7, 19, 94, 5])) # 94
if __name__ == "__main__":
main()