input: Write a function to return the maximum number in a list. The function should iterate through the list and keep updating the maximum value found so far. If the list is empty, the function should return None.
  def find_max(nums):
      '''Returns the maximum number in the list.'''
      if not nums:
          return None
      max_val = nums[0]
      for num in nums:
          if num > max_val:
              max_val = num
      return max_val
  
  assert find_max([1, 15, 20, 6]) == 20
  assert find_max([5, 10, 15, 20]) == 20
  assert find_max([2, 3, 1]) == 3
  assert find_max([1]) == 1
  assert find_max([]) == None
output: def find_max(nums):
      if not nums:
          return None
      max_val = nums[0]
      for num in nums:
          if num > max_val:
              max_val = num
      return max_val