title: Creating a dictionary from a dictionary in python
body: <pre><code>text=&quot;we are in pakistan and love pakistan and olx&quot;
  dict1={&quot;pakistan&quot;: &quot;COUNTRY&quot;, &quot;olx&quot;: &quot;ORG&quot;}
  </code></pre>
  <p>I need to match the key in the text, if it exists store the indices of that word as keys in new dictionary where as the value should be the same as in dict1 for that particular word, for eg the output should be like this:</p>
  <pre><code>dict2={[10:17]:&quot;COUNTRY&quot;,[27:34]:&quot;COUNTRY&quot;,&quot;[40:42]:&quot;ORG&quot;}
  </code></pre>