From f38114a94bac37f3a86e04934ac72c0ac8da563e Mon Sep 17 00:00:00 2001 From: gellikeerthi Date: Tue, 25 Nov 2025 09:58:18 +0530 Subject: [PATCH] Add word counting function in count_words.py Added a new Python program to count the number of words in a given text. --- Strings/count_words.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Strings/count_words.py diff --git a/Strings/count_words.py b/Strings/count_words.py new file mode 100644 index 0000000..0f28d73 --- /dev/null +++ b/Strings/count_words.py @@ -0,0 +1,6 @@ +def count_words(s: str) -> int: + return len(s.split()) + +if __name__ == "__main__": + text = input() + print(count_words(text))