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