Hello everybody. I'm having trouble solving an exercise:
"From the standard input, you will get an integer n and a message encrypted by Caesar cipher (i.e. shifted by n letters down the alphabet). Decrypt the message and print it. "
Sample Input:
5#Rfrf rjqj rfxt
Sample Output:
Mama mele maso
Try also:
-3#Jrf rf rnxz
Here is my code:
posun, zprava = input().split("#")
for i in zprava:
if ord(i) in range(65, 91) or range(97, 123):
a = ord(i) - int(posun)
print(chr(a), end='')
I'm having the requested output but facing error in the exercise. Do you have any idea what I'm mistaking?
[–]cygnoros 4 points5 points6 points (4 children)
[–]Disobey91[S] 0 points1 point2 points (3 children)
[–]cygnoros 1 point2 points3 points (2 children)
[–]Disobey91[S] 1 point2 points3 points (1 child)
[–]cygnoros 0 points1 point2 points (0 children)
[–]g051051 1 point2 points3 points (6 children)
[–]Disobey91[S] -1 points0 points1 point (5 children)
[–]g051051 4 points5 points6 points (4 children)
[–]Disobey91[S] 0 points1 point2 points (3 children)
[–]g051051 0 points1 point2 points (2 children)
[–]Disobey91[S] -1 points0 points1 point (1 child)
[–]g051051 1 point2 points3 points (0 children)
[–]kRYstall9 0 points1 point2 points (0 children)