Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First: list comprehension, reverse splicing, split & join solution in Creative category for Backward Each Word by leggewie
# Explanation:
# split(' ') to keep the spaces in the list
# the outer [] is a list comprehension, google the term if you are unaware of it
# [::-1]reverses a list (each word is a list of letters to python]
# use join to create a string from the list
def backward_string_by_word(text: str) -> str:
return " ".join([word[::-1] for word in text.split(' ')])
May 24, 2021