I have a dictionary like this:
{'some_company_100': {'key1': 'value1',
  'key2': 'value2',
  'key3': 'value3',
  'key4': 'value4',
  'key5': 'value5',
  'key6': {'key6_1': 'value6_1', 'key6_2': 'value6_2'},
  'key7': 'value7'},
 'some_company_101': {'key1': 'valuea',
  'key2': 'valueb',
  'key3': 'valuec',
  'key4': 'valued',
  'key5': 'valuee',
  'key6': {'keyf_1': 'valuef_1', 'keyf_2': 'valuef_2'},
  'key7': 'value7'}}
What I need to take out these inner dictionary out to get rid of the nested dictionary. The way I've tried:
for key, value in final_dict.iteritems():
    for k, v in value.copy().iteritems():
        if isinstance(v, dict):
            value.update(v)
            del[k]
But the problem is that the iteration in the inner dictionary must be doing on copy() of the dictionary so I can't delete k if v isinstance on my original dictionary after getting out v. If I exclude .copy() from value.copy().iteritems(). it returns me an error: `RuntimeError: dictionary changed size during iteration. And to mention, I tried to create this to be universal, not to use
if k=='key6':
    do something
.
Desired output:
{'some_company_100': {'key1': 'value1',
  'key2': 'value2',
  'key3': 'value3',
  'key4': 'value4',
  'key5': 'value5',
  'key6_1': 'value6_1',
  'key6_2': 'value6_2',
  'key7': 'value7'},
 'some_company_101': {'key1': 'valuea',
  'key1': 'valueb',
  'key2': 'valuec',
  'key4': 'valued',
  'key5': 'valuee', 
  'key6_1': 'value6_a', 
  'key6_2': 'value6_b'
  'key7': 'value7'}}
 
     
    