본문 바로가기
python-algorithm

leetcode 557. Reverse Words in a String III

by 무적김두칠 2022. 3. 17.

1
2
3
4
5
6
7
class Solution:
    def reverseWords(self, s: str-> str:
        s=list(s.split())
        ans=''
        for i in s:
            ans+=i[::-1]+' '
        return ans[:-1]
cs
반응형

댓글