title: Count the number of spaces between words in a string
body: <p>I am doing <a href="https://www.hackerrank.com/challenges/capitalize" rel="nofollow noreferrer">this</a> problem on Hackerrank,and I came up with the idea, which includes splitting the input and join it afterwards (see my implementation below).  However, one of the test cases contains the input (<strong>hello</strong>&lt; multiple spaces> <strong>world</strong>), which crashed my code because the input string has more than 1 space between each words.  So, I am just wondering if anyone could please help me out fix my code, and I am just wondering how to count how many spaces(esp multiple spaces) in a string in Python.  I found how to count spaces in Java, but not in Python.  For testcase, I attached the pic.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong><em>My implementation:</em></strong></p>
  
  <pre><code>input_string = input()
  
  splitter = input_string.split()
  
  final = []
  
  for i in range(0,len(splitter)):
      for j in range(0,len(splitter[i])):
          if(j==0):
              final.append(splitter[i][j].upper())
          else:
              final.append(splitter[i][j])
      # Assumed that there is one space btw each words
      final.append(' ')
  print(''.join(final))
  </code></pre>
  
  <blockquote>
    <p>For Test case pic,</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/mx6AZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mx6AZ.png" alt="enter image description here"></a></p>