题解 | #字符串变形#
字符串变形
https://www.nowcoder.com/practice/c3120c1c1bc44ad986259c0cf0f0b80e
class Solution: def trans(self , s: str, n: int) -> str: # write code here lst = s.split(' ') lst = lst[::-1] res = [] for word in lst: tmp = '' for c in word: if c.islower(): tmp += c.upper() elif c.isupper(): tmp += c.lower() res.append(tmp) return ' '.join(res)