'How to Reverse an array in groups in python?

I am trying to reverse the array in groups but I am getting this error:

:----  for i in arr: TypeError: 'NoneType' object is not iterable. 

What's wrong with my code?

   def reverseSubarray(arr,n,k):
      if k == 1:
        return
      i = 0
      while i < n:
        l = i
        r = min(i+k-1, n-1)
        while l < r:
          temp = arr[l]
          arr[l] = arr[r]
          arr[r] = temp
          l += 1
          r -= 1
        i += k
      return arr
    
    def main():
        n = int(input().strip())
        string  = input().strip().split()
        arr=[]
        for j in string:
            arr.append(int(j.strip()))
        k=int(input().strip())
        arr = reverseSubarray(arr,n,k)
        for i in arr:
            print(i,end=' ')
    
    if __name__ == "__main__":
        main()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source