DAY 23 of PYTHON top 100 questions : from Basic to Advanced !!

DAY 23 of PYTHON top 100 questions : from Basic to Advanced !!

Write a Python program to count the number of words in a given string

#Write a Python program to count the number of words in a given string

word = input("enter the word : ")

split_word=word.split()

print(len(split_word))

Output :

enter the word :
Hello learner welcome to my blog
6

It takes user input, splits the input string into words using whitespace as the delimiter, and then prints the count of words.


If you are a beginner and want to know more about Python programming, you can read my Basics of Python blogs (From part 1 to part 15).


HAPPY LEARNING !!!