title: Finding the index of a common character in a for loop
body: <p>First of all I know this is probably a [duplicate] but I could not find the answer to my question specifically anywhere.</p>
  <p>I have a string generated by the user that I want my program to iterate over. Everything goes fine except for the fact that because I'm trying to access the index of a character <code>&quot; &quot;</code> (space) which appears more than once, whenever I try getting the index of the newly assigned <code>space</code> value for <code>&quot; &quot;</code>, it automatically gives me the index of the first <code>&quot; &quot;</code> in the string. I want this program to differentiate between words and create a list with the words in the string using a space to distinguish between them. What am I doing wrong?</p>
  <pre><code>list_words=[]
  def findwords(sentence):
      index1=0
      index2=0
      for space in sentence:
          if space==&quot; &quot;:
              index1=sentence.index(space)
              list_words.append(sentence[index2:index1])
              index2=index1  
      print(list_words)
  findwords(&quot;What is your name?&quot;)
  </code></pre>