0
How can i make the python program define the space
Q=input() Space=0 Word=0 #input "hello world!" for i in Q: if i== "#definition of the space" : Space+=1 else: Word+=1
3 Respostas
+ 3
if i == ' '
+ 2
Mohamed El Mujtaba This code will not count the words that is given as input, rather it only counts the characters (without spaces)
+ 1
Deepraj Baidya it can count the words if i add 1 to the spaces after the (if statement)
"Num of spaces + 1 = Num of words"