← 返回题库
初级

简单密码

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve(s):
    result = ''
    for c in s:
        if c.isupper():
            result += chr((ord(c.lower()) - ord('a') + 1) % 26 + ord('a'))
        elif c.islower():
            if c in 'abc': result += '2'
            elif c in 'def': result += '3'
            elif c in 'ghi': result += '4'
            elif c in 'jkl': result += '5'
            elif c in 'mno': result += '6'
            elif c in 'pqrs': result += '7'
            elif c in 'tuv': result += '8'
            else: result += '9'
        else:
            result += c
    print(result)

示例

输入
YUANzhi1987
期望输出
zvbo9441987
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码