Py||Encode

题目描述
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='')
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值