Friends, the task is the following: Dana encryption lattice and encrypted password, as a list (list) of lines. Example:
('X...', '..X.', 'X..X', '....'), ('itdf', 'gdce', 'aton', 'qrdi')) It is necessary to "overlay" the first list with the second one to receive values from the second list if the symbol in one list corresponds to the symbol "X" in another list. Next, turn the matrix with the characters "X" and perform the operation again. 90, 180, 270. The values obtained from the second list - to the conclusion.
I wrote the solution to this problem, I ask you to look and make comments on the code I wrote.
def recall_password(cipher_grille, ciphered_password): list = "" #Список, где будут храниться полученные данные turn = 0 #Счетчик while turn < 4: for elem1, elem2 in zip(ciphered_password, cipher_grille): #Заходим в каждый из списков for word1, word2 in zip(elem1, elem2): #Получаем значения из каждого списка if word2 == "X": list += word1 cipher_grille = tuple(zip(*cipher_grille[::-1])) #Поворачиваем матрицу на 90 градусов" turn += 1 print(list) return list My decision about the while loop and the counter seems to be ugly, I hope you can suggest how you can make the code "simpotichnoe." thank