8

I'm having an interesting (albeit frustrating) issue with Python.

I'm attempting to populate a 2d array called plaintexts based on some calculations, and I've found that all of the entries in this array are duplicated. Ie, plaintexts[0] == plaintexts[1] == ... == plaintexts[n]. I assumed I messed up value assignment so I tried to halve my code to find the issue, but after a fruitless hour I assigned a value to plaintexts[0][3] at the end of my code and lo and behold, that same value popped up in every other row.

Below is my relevant code:

placeholder = ['0'] * 33
plaintexts = [placeholder] * len(ciphers)

for i in range(2): 
    for j in range(1, 2): 
        for k in range(0,len(ciphers[0])-1,2):
            .
            .
            .
            .
            if charType == '010':
                if(plaintexts[i][k/2] != '0'): 
                  .
                  .
                  .
                  .
                else:
                    plaintexts[i][k/2] = (' ', xorstr.lower())
                  .
                  .
                  .
                  .

plaintexts[0][3] = '13414113133'
print plaintexts[0][3]
print plaintexts[1][3]
print plaintexts

I'd appreciate any help in figuring out the issue.

jackwise
  • 324
  • 1
  • 15

0 Answers0