title: How to find the last matched key by comparing with list and dictionary
body: <p>A list and dictionary is below</p>
  <pre><code>main_list = [&quot;projecttype&quot;,&quot;emptype&quot;,&quot;Designation&quot;]
  sample = {&quot;query&quot;: {
        &quot;emptype&quot;:[&quot;Manager&quot;],&quot;projecttype&quot;:[&quot;temp&quot;],
      &quot;from&quot;: [
        &quot;0&quot;
      ],
      &quot;q&quot;: [
        &quot;&quot;
      ],
      &quot;size&quot;: [
        &quot;4&quot;
      ]
    }}
  </code></pre>
  <ol>
  <li><p>How to find from the main_list which key is <code>last</code> &quot;entered key&quot; in sample dictionary</p>
  </li>
  <li><p>How to find from the main_list which key is <code>first</code> &quot;entered key&quot; in sample dictionary</p>
  </li>
  </ol>
  <p>In this particular scenario</p>
  <ol>
  <li><code>&quot;projecttype&quot;</code> is my output for last entered key which matches</li>
  <li><code>emptype</code> is my output for first entered key which matches</li>
  </ol>