题目描述
Encode the input word, foe example, “China”, the rule is: replace the original letter with the fourth letter after the original letter.
For example, the fourth letter after “A” is “E”, replace “A” with “E”. In this way, “China” should be changed to “Glmre”.
Write a program to make the value of cl, c2, c3, c4, c5 variables’ C ', ‘h’, ‘I’, ‘n’, ‘a’ with the method of assigning initial value. After operation, make c1, c2, c3, c4, c5 become ‘G’, ‘l’, ‘m’, ‘r’, ‘e’, and output.
It should be noted that a is the next letter of z.
输入
A English word, like China
输出
The encoded word
样例输入 Copy
China
样例输出 Copy
Glmre
提示
ASCII code conversion. You can use python function ord(‘a’) to get ASCII code of a letter. The ASCII code of ‘A’ and ‘a’ is 65 and 97 respectively. If you want to verify a letter is a upper letter or not, you can use python function ch.isupper(), which will return true if ch is a upper letter.
n=input()
for i in n:
if(i>='a'):
if(i>'v'):
i=(chr(ord(i)+4-26))
print(i,end='')
else:
i=(chr(ord(i)+4))
print(i,end='')
if(i<='Z'):
if(i>'V'):
i=(chr(ord(i)+4-26))
print(i,end='')
else:
i=(chr(ord(i)+4))
print(i,end='')