I want to decrypt the code via a txt file. But I got an error ord () expected a character, but a string of length 586 was found. Any suggestions for fix it? (i use python 3.9)
def decrypt(string, shift):
cipher = ''
for char in string:
if char == ' ':
cipher = cipher + char
elif char.isupper():
cipher = cipher + chr((ord(char) - shift - 65) % 26 + 65)
else:
cipher = cipher + chr((ord(char) - shift - 97) % 26 + 97)
return cipher
text = open(input("enter string: "))
s = int(input("enter shift number: "))
print("original string: ", text)
print("after decryption: ", decrypt(text, s))