input: Write a function in Python to take as input two arrays of integers and swap their elements. The function should return the swapped arrays. Both arrays must be of the same length for the swap to be valid.
  
  
  def swap(arr1, arr2):
      assert len(arr1) == len(arr2), "Both arrays must be of the same length"
      for i in range(len(arr1)):
          arr1[i], arr2[i] = arr2[i], arr1[i]
      return arr1, arr2
  
  # Test cases
  assert swap([3, 5, 6, 9], [2, 4, 7, 8]) == ([2, 4, 7, 8], [3, 5, 6, 9])
  assert swap([1, 2, 3], [4, 5, 6]) == ([4, 5, 6], [1, 2, 3])
  assert swap([9, 8, 7, 6], [5, 4, 3, 2]) == ([5, 4, 3, 2], [9, 8, 7, 6])
  assert swap([], []) == ([], [])
  
output: def swap(arr1, arr2):
      for i in range(len(arr1)):
          arr1[i], arr2[i] = arr2[i], arr1[i]
      return arr1, arr2