alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ciphertext = "HMYKZ RWAENH CRFMEFZUGHBKZNG OC DILAENBI ML MRKDELQ I HWMR YNI HIM FAO PBGHAF ECSEFOC HWT YNI FOVQINR OJD HWT TI ESVKOT TBKD TBCQBU AHIRF"
plaintext = ""
words = ciphertext.split(' ')
for word in words:
for i in range(len(word)):
if i == 0:
plaintext += word[i]
else:
idxA = alphabet.find(word[i])
idxB = alphabet.find(word[i - 1])
idx = (idxA - idxB - 1 + len(alphabet)) % len(alphabet)
plaintext += alphabet[idx]
plaintext += " "
print(plaintext)
Click Run or press shift + ENTER to run code