Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Reversing lists and negative slicing solution in Clear category for Backward Each Word by undead2k
def backward_string_by_word(text: str) -> str:
split_text = text.split(' ') # Split the string into a list
reversed_text = ' '.join(reversed(split_text)) # Reverse the order (so "hello world" becomes "world hello" and join the list to make a string again
return reversed_text[::-1] # negative slicing returns everything backwards which gives us "olleh dlrow"
May 18, 2020
Comments: