题解 | #字符串变形#

字符串变形

https://www.nowcoder.com/practice/c3120c1c1bc44ad986259c0cf0f0b80e

class Solution:
    def trans(self , s: str, n: int) -> str:
        # write code here
        s_list = s.split(" ")[::-1]
        ans_list = []
        for word in s_list:
            new = ""
            for ch in word:
                if ord("a") <= ord(ch) <= ord("z"):
                    new = new + ch.upper()
                else:
                    new = new + ch.lower()
            ans_list.append(new)
        return " ".join(ans_list)


全部评论

相关推荐

2025-12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务