其他分享
首页 > 其他分享> > openjudge:大小写字母互换

openjudge:大小写字母互换

作者:互联网

描述

把一个字符串中所有出现的大写字母都替换成小写字母,同时把小写字母替换成大写字母。

输入

输入一行:待互换的字符串。

输出

输出一行:完成互换的字符串(字符串长度小于80)。

样例输入

If so, you already have a Google Account. You can sign in on the right. 

样例输出

iF SO, YOU ALREADY HAVE A gOOGLE aCCOUNT. yOU CAN SIGN IN ON THE RIGHT. 

代码

s = input()
for c in s:
    if 'a' <= c <= 'z':
        print(chr(ord(c) - 32 ),end="")
    elif 'A' <= c <= 'Z':
        print(chr(ord(c) + 32),end="")
    else:
        print(c,end="")

标签:小写字母,样例,替换成,大写字母,互换,字符串,openjudge
来源: https://blog.csdn.net/m0_62919535/article/details/122766706