I have large files contain cipher texts. the ciphers are connected like this
QJFQFJDOVRVLHSVUJNHTZDGLDOVGSAYFKFPSAJSOEGXCDHCDDEWGTUUFOVDGQUJD
my question is how can I split the letters so I can for loop each letter?
I'm trying this code but I get this error message
num = (ord(symbol)-k) % 126
TypeError: ord() expected string of length 1, but list found"
with open(file) as f:
translated = ''
for s in f:
symbol = s.split()
print(symbol)
num = (ord(symbol)-k) % 126
if num < 32:
num += 95
translated += chr(num)
print(translated)
before adding .split()
function I got this error message:
"TypeError: ord() expected a character, but string of length 6 found"
with this code:
with open(file) as f:
translated = ''
for symbol in f:
print(symbol)
num = (ord(symbol)-k) % 126
if num < 32:
num += 95
translated += chr(num)
print(translated)
My ciphert contains no white spaces
Thank you
s
is the line in the file . . . you'll want to iterate over that, and python lets you iterate over strings directly (i.e.for _ in s
) – ernie