What I want to do is to take a string(cipher) and devide it to several groups and not to copy them (assume that every 7 characters to one group), All I want to do is take every 7 letters and add them to one row in two dimentional array and the same for the next 7 and so on.
I have tried to do that with two dimentional array and I have some problem that its always change all my arrays for every update, and I dont want to copy it.
Let me give you an example:
def splitter(cipher,key_length):
rows = math.ceil(len(cipher)/key_length)
columns = key_length
arr = [[""]*columns]*rows
arr1=[]
for row in range(rows):
for column in range(columns):
if (row * columns + column)< len(cipher):
arr[row][column] = cipher[row * columns + column]
else:
arr[row][column] = ""
arr1.append(arr[row])
print(arr1)
splitter("QPWKALVRXCQZIKGRBPFAEOMFLJMSDZVDHXCXJYEBIMTRQWNMEAIZRVKCVKVLXNEICFZPZCZZHKMLVZVZIZRRQWDKECHOSNYXXLSPMYKVQXJTDCIOMEEXDQVSRXLRLKZHOV",7)
the result of the print is that its duplicated the least 7 characters for the all array, and I coudnt figure out why this happening, what I'm missing?
the result of this print is:
[['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', ''], ['Z', 'H', 'O', 'V', '', '', '']]