**It takes Input as a string such as this - \'Nice one\' And Output gives - 4,3 (which is no. Of words in sentence or string) **
function countx(str)
local cou
def countLenWords(s):
s=s.split(" ")
s=map(len,s)
s=map(str,s)
s=list(s)
return s
The above functions returns a list containing number of characters in each word
s=s.split(" ")
splits string with delimiter " " (space)
s=map(len,s)
maps the words into length of the words in int
s=map(str,s)
maps the values into string
s=list(s)
converts map
object to list
Short version of above function (all in one line)
def countLenWords(s):
return list(map(str,map(len,s.split(" "))))