Ask 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, countWords ("Mary had a little lamb") should return 5.

+3
Answers (1)
  1. 20 October, 16:14
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers