input: Write a function to randomly select one element from a given array. The function should return the selected element. If the given array is empty, the function should raise an error.
  
  assert randomElement([1, 2, 3, 4]) in [1, 2, 3, 4]
  assert randomElement(['apple', 'banana', 'orange']) in ['apple', 'banana', 'orange']
  try:
      randomElement([])
      assert False, "Expected an error for an empty array"
  except IndexError:
      pass
output: import random
  
  def randomElement(arr):
      if not arr:
          raise IndexError("Array is empty")
      return random.choice(arr)