+ 1

Someone answer this problem..ill give u a surprise then..

a program that will count the number of words in a sentence by the user.

31st Mar 2018, 2:29 AM
ronie
10 Answers
+ 9
string = "words in a sentence" print(len(string.split(" ")))
31st Mar 2018, 2:35 AM
Toni Isotalo
Toni Isotalo - avatar
+ 3
If this is a challenge for us, please submit this as an assignment in the Lesson Factory if you haven't yet 😊 https://www.sololearn.com/discuss/1082512/?ref=app
31st Mar 2018, 2:49 AM
Learnsolo
+ 2
Just take the input, count whitespaces, add 1. Assuming correct input, at least.
31st Mar 2018, 2:31 AM
J.G.
J.G. - avatar
+ 1
myString=input("Enter a sentence") myList=myString.split(" ") wordCount=len(myList) print(wordCount) This is basically the same code, but i will break down what's happening.. line 1 ... get user input and store it as a string line 2 ... split the string into a list. split each word at empty spaces line 3 ... get the word count by checking the length of the list line 4 ... Print the word count
31st Mar 2018, 2:56 AM
LordHill
LordHill - avatar
+ 1
ty sir..ill try to code this
31st Mar 2018, 2:57 AM
ronie
+ 1
if u r talking about js, then heres the code... a=prompt("enter a string"); b=a.split(" ").join(""); document.write(b.length);
31st Mar 2018, 3:45 AM
2+2=4
2+2=4 - avatar
+ 1
ty for following me sir.. hope you can help me more..im still a beginner..thankyou
31st Mar 2018, 1:05 PM
ronie
0
i really dont have an idea sir..huhu..im so embarass
31st Mar 2018, 2:34 AM
ronie
0
how to do that in particular?
31st Mar 2018, 2:35 AM
ronie
0
what if the user will the one to input the number and get the avg.?
31st Mar 2018, 2:42 AM
ronie