Mirror Each Word

Python for AIMedium+10 XP+10

Mirror Each Word

A puzzle reverses the letters of each word, but keeps the words in their original order.

Task: write mirror_words(sentence) that returns the new sentence.

  • Words are separated by any amount of whitespace.
  • In the result, words are separated by exactly one space, with no spaces at the ends.
  • Empty text gives "".

Examples

sentence = "hello world"
returns 'olleh dlrow'
sentence = "Python"
returns 'nohtyP'

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run