Given a string , You need to reverse the character order of each word in the string , Keep the initial order of spaces and words .
Example 1:
Input : "Let's take LeetCode contest"
Output : "s'teL ekat edoCteeL tsetnoc"
Be careful : In the string , Each word is separated by a single space , And there won't be any extra spaces in the string .
Ideas :python Handle , First split Split into a list , Then turn each item over in a list generation , Reuse join Put it together .
class Solution:
def reverseWords(self, s: str) -> str:
return " ".join(word[::-1] for word in s.split())