Python String ifadeyi matrix şeklinde yazma

Screenshot_1
Screenshot_2
Yukarıda ki resimlerdeki gibi bir çıktı almak istiyorum kodum bu şekilde. Sonuç doğru ama sonucu matrix şeklinde bir çıktı olması gerekiyor.
Almak istediğim çıktı:
1.RESİM
K I I Q F
I P U Y Q
O R T G E
U G Q L I
U U E Q Y

  1. Resim
    I U Y Q I Y
    U I T G F E
    O U P Q L Q
    K I G R E Q
def cypher(target,shift):
    alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    for index in range(len(alphabet)):
        if alphabet[index]==target:
            x = index+shift
            y = x % len(alphabet)
            return alphabet[y]
string=input("Metin Giriniz:") #reenforcementsbeingrushed #REENFORCEMENTSBEINGRUSHED
string=string.upper()
shift=int(input("Şifre Giriniz:")) #74030274
shiftstr=str(shift)
encrypted_string=""
for index in range(len(string)):
    a=index
    for index in range(len(shiftstr)):
        b=index
        if a%len(shiftstr) == b:
            encrypted_string+=cypher(string[a],int(shiftstr[b]))
print("Encrypted :",encrypted_string)
decrypted_string=''
for index in range(len(encrypted_string)):
    a=index
    for index in range(len(shiftstr)):
        b=index
        if a%len(shiftstr) == b:
            decrypted_string+=cypher(encrypted_string[a],-int(shiftstr[b]))
print("Decrypted : ",decrypted_string)

Böyle bir kod denemedim ama Tkinder ile arayüz tasarlarken böyle bir sonucu göstermiyor.

X = [[encrypted_string[24:25],encrypted_string[23:24],encrypted_string[22:23],encrypted_string[21:22],encrypted_string[20:21]],
        [encrypted_string[15:16],encrypted_string[16:17],encrypted_string[17:18],encrypted_string[18:19],encrypted_string[19:20]],
        [encrypted_string[14:15],encrypted_string[13:14],encrypted_string[12:13],encrypted_string[11:12],encrypted_string[10:11]],
        [encrypted_string[5:6],encrypted_string[6:7],encrypted_string[7:8],encrypted_string[8:9],encrypted_string[9:10]],
        [encrypted_string[4:5],encrypted_string[3:4],encrypted_string[2:3],encrypted_string[1:2],encrypted_string[0:1]]]

result = [[0,0,0,0,0],
         [0,0,0,0,0],
         [0,0,0,0,0],
         [0,0,0,0,0],
         [0,0,0,0,0]]

# iterate through rows
for i in range(len(X)):
   # iterate through columns
   for j in range(len(X[0])):
       result[j][i] = X[i][j]

for r in result:
   print(r)

Screenshot_6

bu şekil çıkıyor yardımcı olabilir misiniz ? Teşekkür ederim. İyi akşamlar.

decrypted_matrix = "\n".join([decrypted_string[i:i+5] for i in range(0, len(decrypted_string), 5)])

Ikincisi nasil oyle cikiyor anlamadim.

X’i transpoze etmektense (veya herhangi bir operasyondan gecirmektense) olustururken kullanilan indisler degistirilebilir:

X = [[y[0], y[1]], [y[2], y[3]]]
...
Xt[i][j] = X[j][i]

yerine

Xt = [[y[0], y[2]], [y[1], y[3]]]

gibi.