The below code is changing the value of the list K automatically, please help me know why
1
4
1 2 4 3
I gave the above input
The output is this
[1, 2, 3, 4]
[1, 2, 3, 4] 1
[1, 2, 3, 4] 2
1 1
[1, 2, 3, 4] 2
2 2
[1, 2, 3, 4] 2
3 4
[1, 2, 3, 4] 2
4 3
[1, 2, 4, 3]
[1, 2, 4, 3] 1
[1, 2, 4, 3] 2
1 1
[1, 2, 4, 3] 2
2 2
[1, 2, 4, 3] 2
4 4
[1, 2, 4, 4] 2
4 3
[1, 2, 4, 4]
[1, 2, 4, 4]
In the last steps the value of list k changed automatically.
This was done on PyPy 3 and python 3.7
t=int(input())
while t!=0:
    t-=1
    n=int(input())
    h=[0]*n
    lt=[0]*n
    c=0
    l=[int(i) for i in input().split()]
    k=[i for i in range(1,n+1)]
    print(k)
    while c!=7:
        print(k, end=" ")
        print("1")
        c+=1
        for i in range(n):
            print(k, end=" ")
            print("2")
            lt[l[i]-1]=k[i]
            print(k[i],end =" ")
            print(l[i])
        k=lt
        print(k)
        for i in range(n):
            if k[i]==l[i] and h[k[i]-1]==0:
                h[k[i]-1]=c
    print(*h,sep=" ")
 
    