From 699bc1b3aae0a3f67e170737578c17dbc5fa24b2 Mon Sep 17 00:00:00 2001 From: gayangitharaka Date: Thu, 17 Oct 2019 20:04:19 +0530 Subject: [PATCH] added count --- count.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 count.py diff --git a/count.py b/count.py new file mode 100644 index 0000000..6935d53 --- /dev/null +++ b/count.py @@ -0,0 +1,9 @@ +# Python Program - Count Word in Sentence + +print("Enter 'x' for exit."); +string = input("Enter any string to count word: "); +if string == 'x': + exit(); +else: + word_length = len(string.split()); + print("\nNumber of words =",word_length); \ No newline at end of file