title: Delete a nested dictionary from a list of dictionary on a condition?
body: <p>I have the following dictionary with nested dict. I want to remove the nested dictionary if the key (object-name) has apple in it else keep it.</p>
  <p><strong>Input</strong></p>
  <pre><code>{
      &quot;item&quot;: [
          {
              &quot;seq_key&quot;: [
                  {
                      &quot;height&quot;: 153,
                      &quot;object-name&quot;: &quot;person:1&quot;
                  },
                  {
                      &quot;height&quot;: 107,
                      &quot;object-name&quot;: &quot;apple:1&quot;
                  },
                  {
                      &quot;height&quot;: 90,
                      &quot;object-name&quot;: &quot;orange:2&quot;
                  },
                  {
                      &quot;height&quot;: 84,
                      &quot;object-name&quot;: &quot;apple:3&quot;
                  },
                  {
                      &quot;height&quot;: 94,
                      &quot;object-name&quot;: &quot;apple:4&quot;
                  }
              ],
              &quot;f-no&quot;: &quot;0&quot;
          },
          {
              &quot;seq_key&quot;: [
                  {
                      &quot;height&quot;: 161,
                      &quot;object-name&quot;: &quot;person:1&quot;
                  },
                  {
                      &quot;height&quot;: 84,
                      &quot;object-name&quot;: &quot;mango:3&quot;
                  }
              ],
              &quot;f-no&quot;: &quot;1&quot;
          }
      ]
  }
  
  </code></pre>
  <p><strong>My Expected Output</strong></p>
  <pre><code>{
      &quot;item&quot;: [
          {
              &quot;seq_key&quot;: [
                  {
                      &quot;height&quot;: 153,
                      &quot;object-name&quot;: &quot;person:1&quot;
                  },
                  {
                      &quot;height&quot;: 90,
                      &quot;object-name&quot;: &quot;orange:2&quot;
                  }
              ],
              &quot;f-no&quot;: &quot;0&quot;
          },
          {
              &quot;seq_key&quot;: [
                  {
                      &quot;height&quot;: 161,
                      &quot;object-name&quot;: &quot;person:1&quot;
                  },
                  {
                      &quot;height&quot;: 84,
                      &quot;object-name&quot;: &quot;mango:3&quot;
                  }
              ],
              &quot;f-no&quot;: &quot;1&quot;
          }
      ]
  }
  
  </code></pre>
  <p><strong>What i tried</strong></p>
  <pre><code>import json 
  
  with open(r&quot;my_file.json&quot;, encoding='utf-8') as f:
      abc = json.load(f)
  
  for key,value in abc.items():
      for i in value:
          for n,item in enumerate(i.get('seq_key')):
              if item.get('object-name').split(&quot;:&quot;)[0]  == 'apple':
                  item.clear()
  </code></pre>
  <p>The above code gives empty dict ,I am not sure how to remove from the list. If i try to use list removal method only two items gets removed not all.</p>
  <p>can anyone help me , how to remove it?</p>