0
k=0
m=0 
l=0
for i in range(row*column/16):
    for j in range(16):
        group21x[i][k][m]=seed[l]^group1x[i][k][m]
        k=k+1
        m=m+1
        l=l+1
        if(k==4):
            k=0
        if(m==4):
            m=0

In the following python code the value of group1x before xor operation and after xor operation are different.Why?

Gini John
  • 15
  • 8
  • Possible dup: https://stackoverflow.com/questions/2612802/how-to-clone-or-copy-a-list-in-python – styvane Apr 01 '16 at 09:57

1 Answers1

0

It happens because group21x and group1x are referring to the same data.

Because you didn't added the previous lines to your post, I can't provide something very specific, but this simple example will help you to understand what happens:

v1 = [1, 2]
v2 = v1
v2[0]=0
print(v2)      # [0,2]
print(v1)      # [0,2]

Now, I add [:]:

v1 = [1, 2]
v2 = v1[:]
v2[0]=0
print(v2)      # [0,2]
print(v1)      # [1,2]
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199