# 557. Reverse Words in a String III

#### Easy

Given a string `s`, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

&#x20;

**Example 1:**

<pre><code>Input: s = "Let's take LeetCode contest"
<strong>Output:
</strong> "s'teL ekat edoCteeL tsetnoc"
</code></pre>

**Example 2:**

<pre><code>Input: s = "God Ding"
<strong>Output:
</strong> "doG gniD"
</code></pre>

```python
class Solution:
    def reverseWords(self, s: str) -> str:
        result = ""
        for word in s.split(" "):
            result += word[::-1] + " "
        return result.strip()
```

<br>
