Header Ads Widget

Word count

 

 Program to Count number of words in given sentence

Have the function wordcount (str) take the str string parameter being passed and return the number of words the string contains (e.g. "Never eat shredded wheat or cake" would return 6). Words will be separated by single spaces.


Sample input:

Hello World

Sample output:

2

Browse Resources 
Search for any help or documentation you might need for this problem. For example: array indexing, Ruby hash tables, etc.


Program to Count number of words in given sentence

The objective of the code is to count the number of words in the given sentence . 

Python code:-

def wordCount(strParam):
l=strParam.split()
return len(l)
print(wordCount(input()))

Output:-

Hello World
2

Wipro :-

Infytq :-

Key Points;-

Hackerrank:-


C-tutorial:-

See more:-