Write a Python function to find the maximum and minimum numbers from a sequence of numbers.

Write a Python function to find the maximum and minimum numbers from a sequence of numbers.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def max_min(data):
  l = data[0]
  s = data[0]
  for num in data:
    if num> l:
      l = num
    elif num< s:
        s = num
  return l, s

print(max_min([0, 10, 15, 40, -5, 42, 17, 28, 75]))

Final output

Leave a Comment