count number of spaces in string python

Solutions on MaxInterview for count number of spaces in string python by the best coders in the world

showing results for - "count number of spaces in string python"
Luca
20 Apr 2017
1# '.isspace() ' return True of False for if a character is a space
2
3word = "How many spaces"
4num = 0
5for i in word:
6  if(i.isspace() == True):
7    num += 1
8print(num) #Output: '2'