Backward Each Word
In the process of solving this problem, I used the hints. However, all the hints, up to the final proposed solution, do not satisfy the conditions of the problem.
def backwardstringby_word(text: str) -> str: return ' '.join(x[::-1] for x in text.split(' '))
This solution does not pass the test:
assert backwardstringby_word("hello world") == "olleh dlrow"
This is because the final ' '.join() combines all lines with only one space, however, according to the test condition, we need to save all three spaces. Is there a mistake in the test itself? When I submit the suggested solution for verification on the site, all the tests pass. However, the test fails in the IDE, of course :)