So, I have a txt file with the word 'QWE'. I am trying to print it reversed, but [::-1} does not work in this case.
file = open('10asciitxt.txt', 'r')
while 1:
# read by character
char = file.read(1)
if not char:
break
res=128-ord(char)
print(char," = ",ord(char),"| 128 - ",ord(char)," = ",res," Res: ",chr(res))
file.close()
Output:
Q = 81 | 128 - 81 = 47 Res: /
W = 87 | 128 - 87 = 41 Res: )
E = 69 | 128 - 69 = 59 Res: ;
Expected Output:
E = 69 | 128 - 69 = 59 Res: ;
W = 87 | 128 - 87 = 41 Res: )
Q = 81 | 128 - 81 = 47 Res: /