input: Write a function to find the maximum number in a given list. The function should iterate through the list and keep track of the highest number found. If the list is empty, the function should return None.
  assert max_num([9, 2, 5, 6, 4, 1])==9
  assert max_num([0, -1, -5, -3])==0
  assert max_num([7])==7
  assert max_num([])==None
output: def max_num(lst):
      if not lst:
          return None
      max_val = lst[0]
      for num in lst:
          if num > max_val:
              max_val = num
      return max_val