I am trying to decode enciphered message 'lmnopqrstuvwxyzabcdefghijk'
. I got that it shifted by 11 and I must decipher 'I wtvp olel decfnefcpd lyo lwrzctesxd'
.
Here's what I wrote so far:
#enciphered message = 'I wtvp olel decfnefcpd lyo lwrzctenter code hereesxd'
plain = 'abcdefghijklmnopqrstuvwxyz'
#plain Index= 0123456789........25
cipher = 'lmnopqrstuvwxxyzabcdefghijk'
#11 12 13 14 15 16 17 18 19 20 21 22 23 24 25...12345678910
cipher_text = input('Enter enciphered message: ')
clean_text ='I '
for i in cipher_text:
if cipher_text.index(i) != " ":
clean_text = clean_text + plain.index(cipher[(ord(i)-ord('a'))])
else:
clean_text = clean_text + " "
print(clean_text)
When I ran it:
Enter enciphered message: I wtvp olel decfnefcpd lyo lwrzctesxd
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-97-ac338a9d79fc> in <module>
18 for i in cipher_text:
19 if cipher_text.index(i) != " ":
---> 20 clean_text = clean_text + plain.index(cipher[(ord(i)-ord('a'))])
21 #chr((cipher.index(cipher_text[i]))+ ord('a')) - 11)
22 else:
TypeError: can only concatenate str (not "int") to str
I am very new to Python, and I have no idea how to solve it.
add commend: The enciphered message that I want to decode has capital "I" as well as space between words, so I want to know how to decode capital and lowercase at the same time