Answers for "find number of words in a string python"

0

count number of words in a string python

a_string = "you string here"
word_list = a_string.split()
number_of_words = len(word_list)
print(number_of_words)
Posted by: Guest on February-12-2022
0

number of words in a string python

a_string = "one two three four"
word_list = a_string.split()
print(len(word_list)) # Outputs 4
Posted by: Guest on March-04-2022
1

how to count number of words in a string

String name = "Carmen is a fantastic play"; //arbitrary sentence
        
        int numWords = (name.split("\\s+")).length; //split string based on whitespace
                                                //split returns array - find legth of array
        
        System.out.println(numWords);
Posted by: Guest on June-06-2020

Code answers related to "find number of words in a string python"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language