Q. Write a program that asks the user for a string (only single space between words) and returns an estimate of how many words are in the string. (Hint. Count number of spaces)

 

Answer = 

 

sen = input("Enter the sentance :-")
count = 0
for i in sen :
    if i == " " :
        count += 1
print("number of word =", count + 1)


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post