input: Write a function that takes two matrices as input and returns their sum if they are of the same dimensions, otherwise returns an error message indicating that the matrices are not compatible. The function should check the dimensions of the matrices and then add corresponding elements of the matrices. If the matrices have different dimensions, it should return 'Matrices not compatible'.
  
  
  def add_matrix(matrix1, matrix2):
      if len(matrix1) != len(matrix2):
          return 'Matrices not compatible'
      if len(matrix1[0]) != len(matrix2[0]):
          return 'Matrices not compatible'
      
      rows = len(matrix1)
      cols = len(matrix1[0])
      result = [[matrix1[i][j] + matrix2[i][j] for j in range(cols)] for i in range(rows)]
      
      return result
  
  assert add_matrix([[1, 2], [3, 4]], [[5, 6], [7, 8]]) == [[6, 8], [10, 12]]
  assert add_matrix([[1, 2, 3]], [[4, 5, 6]]) == [[5, 7, 9]]
  assert add_matrix([[1], [2]], [[3], [4]]) == [[4], [6]]
  assert add_matrix([[1, 2]], [[3]]) == 'Matrices not compatible'
  assert add_matrix([[1]], [[2, 3]]) == 'Matrices not compatible'
  
output: def add_matrix(matrix1, matrix2):
      if len(matrix1) != len(matrix2):
          return 'Matrices not compatible'
      if len(matrix1[0]) != len(matrix2[0]):
          return 'Matrices not compatible'
      
      rows = len(matrix1)
      cols = len(matrix1[0])
      result = [[matrix1[i][j] + matrix2[i][j] for j in range(cols)] for i in range(rows)]
      
      return result