def get_len(text): '''function to get the count of words in string''' import re # using regex (findall()) # to count words in string res = len(re.findall(r'w+', text)) return res