#571 · Stacks and queues · Beginner · 35 XP · about 6 min
Push the letters of a word onto a stack, then pop them off again, and they come out backwards. Write reverse_each_word(sentence) that returns sentence with the letters of every word reversed, while the words stay in their places.
A word is any run of characters that are not spaces, so punctuation is reversed with its word. Every space stays exactly where it was, including double spaces and spaces at either end.
reverse_each_word('Hello World') # returns 'olleH dlroW' reverse_each_word('Python is fun!') # returns 'nohtyP si !nuf' reverse_each_word('stack') # returns 'kcats'
First solves only, ranked by stars and then time.