I think this would fail with doubles spaces in a sentence...
That's true :( looks like the right implementation is
def reverse_words(sentence: str) -> str:
return ' '.join(word[::-1] for word in sentence.split())
you don't need to use (' ') to split by spaces :)
That's what happens when you write too much js code 😅 edited thanks!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.