input: Write a function to calculate the sum of an exponential series up to the nth term for a given base x. Return the sum of the series. The given input consists of two integers x and n, where x is the base and n is the number of terms. If either input is invalid, return an error message.
  def exponential_series(x, n):
      if type(x) != int or type(n) != int or n < 0:
          return "Invalid input"
      sum = 0
      for i in range(n + 1):
          sum += x ** i
      return sum
  
  assert exponential_series(2, 3) == 15
  assert exponential_series(3, 0) == 1
  assert exponential_series(-1, 2) == 0
  assert exponential_series(3, 3) == 40
  assert exponential_series("a", 2) == "Invalid input"
output: def exponential_series(x, n):
      if type(x) != int or type(n) != int or n < 0:
          return "Invalid input"
      sum = 0
      for i in range(n + 1):
          sum += x ** i
      return sum