<jupyter_start><jupyter_text>Reverse Words in a String[原题](https://mp.weixin.qq.com/s/7g2oUrzDHpc76rZGm2TsgQ)  QuestionGiven a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.```textInput: "The cat in the hat"Output: "ehT tac ni eht tah"```**Note:** *In the string, each word is separated by single space and there will not be any extra space in the string.*<jupyter_code>class Solution:
    ''' The Solution Class '''
    
    def reverseWords(self, string: str):
        ''' The Main Algorithm '''
        
        # Split the whole string by its space.
        words_list = string.split(' ')
        
        # Reverse every word in the list.
        words_list = [word[-1::-1] for word in words_list]
        
        # Combine them together.
        return ' '.join(words_list)
print(Solution().reverseWords('The cat in the hat'))<jupyter_output>ehT tac ni eht tah
{'fraction_non_alphanumeric': 0.09989594172736732, 'fraction_numerical': 0.007284079084287201, 'mean_word_length': 3.146551724137931, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '113622', 'license': 'MIT', 'n_tokens_mistral': 301, 'n_tokens_neox': 285, 'n_words': 107, 'path': 'March/Week9/58.ipynb', 'repo_name': 'Dragon1573/Daily-Problem', 'size': '961'}