From 8a5b1abd0a2a110db80d4a67c0db979ce3c4cf4e Mon Sep 17 00:00:00 2001 From: Deekshaesha <57080015+Deekshaesha@users.noreply.github.com> Date: Mon, 28 Oct 2019 13:44:53 +0530 Subject: [PATCH] finding max (#1488) * Update find_max.py * Update find_max.py * Format with psf/black and add doctests --- maths/find_max.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/maths/find_max.py b/maths/find_max.py index 7cc82aacf..8b5ab48e6 100644 --- a/maths/find_max.py +++ b/maths/find_max.py @@ -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__":