From 6ee662bcf8c0ff487d9d3afddbd25e6bd45f0a34 Mon Sep 17 00:00:00 2001 From: Ashwek Swamy <39827514+ashwek@users.noreply.github.com> Date: Thu, 1 Nov 2018 09:18:06 +0530 Subject: [PATCH] Update FindMax.py 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 451ba03634a2..0ce49a68c348 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