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)
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)
number of words in a string python
a_string = "one two three four"
word_list = a_string.split()
print(len(word_list)) # Outputs 4
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);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us