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