Menu Close

Word Count

Write a Python program to count the number of entered words in a given string.
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output
Input:
First Line: String or sentence
Second Line: word to be searched in the sentence

Output:
Word Count

string=input("Enter a sentence: ")
find=input("Enter the word: ")
L=string.split()
s=0
for i in range(len(L)):
  if L[i]==find:
    s+=1
print('Count=',s)

Morae!Q!

->Insert and Extend in list python
->Print Odd Numbers in range
->Compare List in python
->Find whether the largest element in the array is at least twice as much as every other number in the array.
->Find minimum cost to reach the top of the floor
->Word Count in Python
->Lower case to upper case in python
->Display Time in python
->Sum of Odd And Even in Python
->Surface Area of Walls
->Find the sum of squares of individual digits
->Print the given series – 1 1 2 6 24
->Minimum number of steps required to reach destination.
->Seconds to Days Hours Minutes
->Program to remove add “Hyphen” character in the entered string
->Remove the nth Index Character from a Non-Empty String
->Relational operator Question
->Check whether all the given numbers lies in range of x and y.
->Find the Armstrong numbers between the given range.