input: Write a function to optimize the Python code for finding the maximum number in a list. If the list is empty, the function should return None.
  assert max_num([9, 2, 5, 6, 4, 1])==9
  assert max_num([25, 30, 15, 20, 10])==30
  assert max_num([-1, -5, -3, -2, -4])==-1
  assert max_num([8])==8
  assert max_num([])==None
output: def max_num(lst):
      if not lst:
          return None
      return max(lst)