0
    %definition of a function

def array_left_rotation(a, n, k):
        b = a
        for i in range (n):
            a[(i-k)%n] = b[i]
        return a;        


    n, k = map(int, raw_input().strip().split(' '))
    a = map(int, raw_input().strip().split(' '))
    answer = array_left_rotation(a, n, k);
    print ' '.join(map(str,answer))

I have observed that list b is also changing on iteration even though it is defined outside the 'for' loop. Can someone tell me, is my assumption correct. if so please suggest the possible solution ?

0 Answers0