how to count number of spacing in python code example
Example 1: count number of spaces in string python
>>> a = "My test string"
>>> a.count(' ')
2
Example 2: number of spaes pythopn
# '.isspace() ' return True of False for if a character is a space
word = "How many spaces"
num = 0
for i in word:
if(i.isspace() == True):
num += 1
print(num) #Output: '2'