Ask Question
21 June, 09:24

Write a function def countWords (stri ng) that returns a count of all words in the string string. Words are separated by spac For example, countWords ("Mary had a little lamb") should return 5.

+1
Answers (1)
  1. 21 June, 12:40
    0
    def w_count (s):

    return (len (s. split ()))

    st=input ('Enter a string:')

    print ("Number of words in given string=", w_count (st))
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a function def countWords (stri ng) that returns a count of all words in the string string. Words are separated by spac For example, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers