Skip to content

Commit 32db8be

Browse files
ashwekyanglbme
authored andcommitted
Update FindMax.py (TheAlgorithms#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.
1 parent d8e3302 commit 32db8be

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Maths/FindMax.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# NguyenU
22

3-
import math
43
def find_max(nums):
5-
max = 0
4+
max = nums[0]
65
for x in nums:
76
if x > max:
87
max = x

0 commit comments

Comments
 (0)