input: Write a function to calculate the average of the elements in a 2-dimensional array. The function should take a 2D array as input and return the average value of all elements in the array. If the array is empty, the function should return 0.
  assert averageMatrix([[3,2,6], [8,5,9], [4,7,1]])==5.0
  assert averageMatrix([[1,2,3], [4,5,6], [7,8,9]])==5.0
  assert averageMatrix([[0,0,0], [0,0,0], [0,0,0]])==0.0
  assert averageMatrix([])==0.0
  assert averageMatrix([[10]])==10.0
output: def averageMatrix(arr):
      if not arr:
          return 0.0
      total = 0
      count = 0
      for row in arr:
          total += sum(row)
          count += len(row)
      return total / count