题解 | #字符串变形#
字符串变形
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)
查看3道真题和解析