input: Write a function to calculate the average of a list of numbers in Python. The function should return the average as a floating point number or 0 if the list is empty. If the list contains non-numeric elements, the function should raise a ValueError.
  assert avg_list([1, 2, 3, 4, 5]) == 3.0
  assert avg_list([10, 20, 30, 40, 50]) == 30.0
  assert avg_list([0, 0, 0]) == 0.0
  assert avg_list([]) == 0
  assert avg_list([1, 'a', 3]) # This should raise a ValueError
  assert avg_list([1.5, 2.5, 3.5]) == 2.5
output: def avg_list(numbers):
      if not numbers:
          return 0
      if not all(isinstance(num, (int, float)) for num in numbers):
          raise ValueError("List contains non-numeric elements")
      return sum(numbers) / len(numbers)