title: How to extract string in Python
body: <p>I want to extract specific string from a string, but it shows error. Why can't I use the find as index to extract string ? </p>
  
  <p>Here is my code</p>
  
  <pre><code>string = 'ABP'
  p_index = string.find('P')
  s = string[0, p_index]
  print(s)
  
  TypeError: string indices must be integers
  </code></pre>