title: Converting a string to array of words - Python
body: <p>I want to create a function in Python, where input will be the String and input it into an array to be returned.  </p>
  
  <p>For example:  </p>
  
  <pre><code>Input: "The dog is red"  
  Output: "The", "dog", "is", "red"
  </code></pre>
  
  <p>I believe the algorithm should work, but nothing is returned. From what I can assume, the if statement is not detecting the space ( "). </p>
  
  <p>The code is below:</p>
  
  <pre><code>string = input("Input here:")
  def token(string):
      start = 0
      i = 0
      token_list = []
      for x in range(0, len(string)):
          if " " == string[i:i+1]:
              token_list = token_list + string[start:i+1]
              print string[start:i+1]
              start = i + 1
          i += 1
      return token_list 
  </code></pre>