pythonic句子中的反词
发布于 2021-01-29 15:12:28
我正在尝试编写pythonic代码以反转句子中的单词
例如:
input: "hello there friend"
output: "friend there hello"
码:
class Solution:
def swap(self, w):
return w[::-1]
def reverseWords(self, s):
w = self.swap(s).split()
return ' '.join(for x in w: swap(x))
使它无法正常工作有点麻烦。我需要有关退货单的帮助
关注者
0
被浏览
51