From 32db8be93e2821900917daec200a0c914b7cc00c Mon Sep 17 00:00:00 2001 From: Ashwek Swamy <39827514+ashwek@users.noreply.github.com> Date: Thu, 1 Nov 2018 19:25:28 +0530 Subject: [PATCH] Update FindMax.py (#588) Issues in previous code: `Line 3` math module is not used so we don't have to import it `Line 5`, `max = 0` will give wrong answer (0) when the list contains only -ve elements, as 0 will always be larger than the elements. --- Maths/FindMax.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Maths/FindMax.py b/Maths/FindMax.py index 451ba0363..0ce49a68c 100644 --- a/Maths/FindMax.py +++ b/Maths/FindMax.py @@ -1,8 +1,7 @@ # NguyenU -import math def find_max(nums): - max = 0 + max = nums[0] for x in nums: if x > max: max = x