题解 | #翻转单词#

翻转单词

http://www.nowcoder.com/practice/aa7e93b78b294a859bb52d5b965aaaf1

#将字符串中以空格为分隔符加入到列表l中
#再将l中元素以空格为分隔符连接成新的字符串,否则返回的是列表
class Solution:
    def reverseWord(self , str: str) -> str:
        # write code here
        l=[]
        for i in str.split(' '):
            l.append(i[::-1])
        return ' '.join(l)
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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