input: Write a function to optimize the given Python program that finds the maximum number in a list. The function should return the maximum number from the provided list. If the list is empty, the function should return None.
  assert max_num([9, 2, 5, 6, 4, 1])==9
  assert max_num([4, 8, 3, 7, 2])==8
  assert max_num([1])==1
  assert max_num([])==None
output: def max_num(lst):
      if not lst:
          return None
      return max(lst)