“compter le nombre de mots dans une chaîne python” Réponses codées

compter le nombre de mots dans une chaîne python

a_string = "you string here"
word_list = a_string.split()
number_of_words = len(word_list)
print(number_of_words)
the hacker man

Compter le nombre de mots dans une chaîne

public static void main (String[] args) {

     System.out.println("Simple Java Word Count Program");

     String str1 = "Today is Holdiay Day";

     String[] wordArray = str1.trim().split("\\s+");
     int wordCount = wordArray.length;

     System.out.println("Word count is = " + wordCount);
}
Ahmad Mujtaba

Comptez les mots dans une chaîne

function WordCount(str) { 
  return str.split(" ").length;
}

console.log(WordCount("hello world"));
Ngoc Chau

Comment compter le nombre de mots dans une chaîne

 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);
Luc Botes

Réponses similaires à “compter le nombre de mots dans une chaîne python”

Questions similaires à “compter le nombre de mots dans une chaîne python”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code