Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Backward Each Word by arun_maiti
def backward_string_by_word(text: str) -> str:
# Divide into a list
new_text = text.split(' ')
result = []
for i in new_text:
# Turn it over and add it to the list
result .append(i[::-1])
# Combine into a line
return ' '.join(result)
print("Example:")
print(backward_string_by_word(""))
# These "asserts" are used for self-checking
assert backward_string_by_word("") == ""
assert backward_string_by_word("world") == "dlrow"
assert backward_string_by_word("hello world") == "olleh dlrow"
assert backward_string_by_word("hello world") == "olleh dlrow"
assert backward_string_by_word("welcome to a game") == "emoclew ot a emag"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Dec. 4, 2025
Comments: