# '.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'