input: Write a function to find the maximum number in a list and optimize it. The function should return the largest number in the list. If the list is empty, it should return None.
  assert max_num([9, 2, 5, 6, 4, 1]) == 9
  assert max_num([10, 20, 30, 40, 50]) == 50
  assert max_num([5]) == 5
  assert max_num([]) == None
output: def max_num(lst):
      if not lst:
          return None
      return max(lst)