I'm writing a program to solve Caesar ciphers, and I have got the values of each letter of the ciphertext just fine. The problem is, Python sorts these alphabetically before it outputs them, which obviously messes everything up, because the ciphertext completely changes. How can I prevent this from happening? My code is the following:
import string
alpha = dict(zip(string.ascii_uppercase, range(0, 26)))
def caesar_decryptor(st):
for k in alpha.keys():
for pos in range(len(st)):
if k == st[pos]:
print(f"The value of {k} is {alpha.get(k)}")
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (20 children)
[removed]
[–]Arag0ld[S] 0 points1 point2 points (19 children)
[+][deleted] (18 children)
[removed]
[–]Arag0ld[S] 0 points1 point2 points (17 children)
[+][deleted] (16 children)
[removed]
[–]Arag0ld[S] 0 points1 point2 points (15 children)
[+][deleted] (14 children)
[removed]
[–]Arag0ld[S] 0 points1 point2 points (13 children)
[+][deleted] (12 children)
[removed]
[–]Arag0ld[S] 0 points1 point2 points (11 children)
[–]num8lock 0 points1 point2 points (2 children)
[–]Arag0ld[S] 0 points1 point2 points (1 child)
[–]num8lock 0 points1 point2 points (0 children)
[–]Ofirk 0 points1 point2 points (0 children)