mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-19 00:37:02 +00:00
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.
This commit is contained in:
parent
d8e33020b4
commit
32db8be93e
|
@ -1,8 +1,7 @@
|
||||||
# NguyenU
|
# NguyenU
|
||||||
|
|
||||||
import math
|
|
||||||
def find_max(nums):
|
def find_max(nums):
|
||||||
max = 0
|
max = nums[0]
|
||||||
for x in nums:
|
for x in nums:
|
||||||
if x > max:
|
if x > max:
|
||||||
max = x
|
max = x
|
||||||
|
|
Loading…
Reference in New Issue
Block a user