Python/Maths/FindMax.py
Ashwek Swamy 32db8be93e 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.
2018-11-01 21:55:28 +08:00

15 lines
203 B
Python

# NguyenU
def find_max(nums):
max = nums[0]
for x in nums:
if x > max:
max = x
print(max)
def main():
find_max([2, 4, 9, 7, 19, 94, 5])
if __name__ == '__main__':
main()