From 11094e4f24a6c323d19581b7adea95ec0a2bc5b7 Mon Sep 17 00:00:00 2001 From: Tithi Joshi Date: Sun, 25 Jan 2026 11:07:51 +0530 Subject: [PATCH] docs: improve docstring clarity in reverse_words Updated function name and docstring for clarity. --- strings/reverse_words.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/strings/reverse_words.py b/strings/reverse_words.py index 504c1c2089dd..bee237f2a2d9 100644 --- a/strings/reverse_words.py +++ b/strings/reverse_words.py @@ -1,12 +1,14 @@ -def reverse_words(input_str: str) -> str: - """ - Reverses words in a given string +def reverse_words(sentence: str) -> str: + """Reverse the order of words in a given string. + + Extra whitespace between words is ignored. + >>> reverse_words("I love Python") 'Python love I' >>> reverse_words("I Love Python") 'Python Love I' """ - return " ".join(input_str.split()[::-1]) + return " ".join(sentence.split()[::-1]) if __name__ == "__main__":