title: Recursively iterate through a nested dict with list, and replace matched values
body: <p>I want to make a function that iterate through a nested dict that include list. For each value that match with a keyword, the function replace it with another keyword.</p>
  
  <p>It's not important if the function return another dict or if it change the main dict.</p>
  
  <p>I tried to separate the case:
  - if the data is a dict, make something
  - if the data is a list, make something else</p>
  
  <p>DICT:</p>
  
  <pre class="lang-py prettyprint-override"><code>
  data_dict = {
    "name": "AAAAAA",
    "content": "BBBBBB",
    "dat": [
      {
        "author": {
          "name": "CCCCCC",
          "surname": "DDDDDD",
        },
        "title": "FFFFFF",
        "color": 15258703,
        "fields": [
          {
            "name": "GGGGGG",
            "value": "HHHHHH",
          },
          {
            "name": "IIIIII",
            "value": "JJJJJJ",
          }
  
        ],
        "thumbnail": {
          "url": "KKKKKK"
        },
        "image": {
          "url": "LLLLLL"
        },
        "footer": {
          "text": "MMMMMMM",
          "icon_url": "NNNNNN"
        }
      }
    ]
  }
  
  
  </code></pre>
  
  <p>Now I'm just trying to change each value to see if I'm iterate as well.
  I can print all the <code>data_dict</code> with value changed, but I can't manage it in a dict...</p>
  
  <pre class="lang-py prettyprint-override"><code>
  def recursive_replace_valuer(data, match, repl):
  
      if isinstance(data, list):
          for l in data:
              recursive_replace_valuer(l, match, repl)
              if isinstance(l, dict):
                  recursive_replace_valuer(l, match, repl)
  
  
  
  
      elif isinstance(data, dict):
          for k,v in data.items():
              recursive_replace_valuer(v, match, repl)
              data[k] = '______'
          print(data)
  
  recursive_replace_valuer(data_dict, 'a','a')
  </code></pre>