title: Indices of matching parentheses in Python
body: <p>Is there a way to get indices of matching parentheses in a string? For example for this one:</p>
  
  <pre><code>text = 'aaaa(bb()()ccc)dd'
  </code></pre>
  
  <p>I'd like to get a dictionary with values:</p>
  
  <pre><code>result = {4:14, 7:8, 9:10}
  </code></pre>
  
  <p>which means that parentheses on index 4 and 14 are matching , 7 and 8 an so on.
  Thanks a lot.</p>