input: Write a function to optimize the given Python program that finds the maximum number in a list. The function should take a list as input and return the maximum number in that list. If the list is empty, the function should return None.
  assert max_num([9, 2, 5, 6, 4, 1])==9
  assert max_num([-3, -5, -1, -2, -4])==-1
  assert max_num([10, 20, 30, 40, 50])==50
  assert max_num([])==None
  assert max_num([7])==7
output: def max_num(lst):
      if not lst:
          return None
      return max(lst)