title: Python: How to extract required information from a string?
body: <p>I am new to Python. Is there a StringTokenizer in Python? Can I do character by character scanning and copying.</p>
  
  <p>I have the following input string</p>
  
  <pre><code>data = '123:Palo Alto, CA -&gt; 456:Seattle, WA 789'
  </code></pre>
  
  <p>I need to extract the two (city, state) fields from this string. Here is the code I wrote</p>
  
  <pre><code>name_list = []
  while i &lt; len(data)):
        if line[i] == ':':
            name = ''
            j = 0
            i = i + 1
            while line[i] != '-' and line[i].isnumeric() == False:
               name[j] = line[i]   # This line gives error
               i = i + 1
               j = j + 1
            name_list.append(name)
        i = i + 1
  </code></pre>
  
  <p>What should I do?</p>