16
a=input("Enter the string paragraph:")
count=0
for i in a:
  if  i==" ":
       count=count+1
       print("Number of spaces in a string:",count)

Count the number of spacing logical program is working

MathisH A
  • 3
  • 2
Myscript
  • 161
  • 1
  • 1
  • 6
  • My question is simple, User has entered the set of character or string , Eg: I a m in the cof fe e sh op. So I wanted to count number of space in the full user input. So totally there are 8 space. and I also want to print at which all position the space is ... – Myscript Nov 23 '15 at 06:16

1 Answers1

26
>>> a=input("Enter the value ")
Enter the value "My Testing String"
>>> a.count(' ')
2
Mayur Koshti
  • 1,688
  • 15
  • 20