reverse_words

Solution

	
	def reverse_words(sentence: str) -> str:
    return " ".join(reversed(sentence.split(" ")))

	

Tests

	
	from publicmatt.leet.problems.reverse_words import reverse_words


def test_simple():
    sentence = "I love long words"
    assert reverse_words(sentence) == "words long love I"


def test_empty():
    sentence = ""
    assert reverse_words(sentence) == ""


def test_another():
    sentence = "I am happy that today is Friday"
    assert reverse_words(sentence) == "Friday is today that happy am I"

	
reverse_words