title: Edit/Rename Key Names in .json dictionary
body: <p>Hello I want to remove part of the name of all keys in my json dictionary</p>
  <p>so what I did is that I generated the names of the files first</p>
  <pre><code>def list_of_files():
      path = '/mnt/c/Users/base'
      files = os.listdir(path)
      for f in files:
          print(files)
          return files
  </code></pre>
  <p>The result</p>
  <pre><code>['test1.txt', 'test2.txt', 'test3.txt']
  </code></pre>
  <p>After that, I loaded the files</p>
  <pre><code>def load_file(filename):
      loadfile = open(&quot;'/base'&quot;+ filename, &quot;r&quot;)
          return(loadfile)
  </code></pre>
  <p>Then I looped through the file names and attached the contents in a json dictionary</p>
  <pre><code>a = list_of_files()
  
  data2 = { i : load_file(i) for i in a }
  </code></pre>
  <p>Then I put all in a json dictionary</p>
  <pre><code>{
  &quot;test1.txt&quot;: [
              &quot;example 1&quot;,
               &quot;Example 2&quot;
               ],
  
  &quot;test2.txt&quot;: [
              &quot;example 1&quot;,
               &quot;Example 2&quot;
               ],
  
  &quot;test3.txt&quot;: [
              &quot;example 1&quot;,
               &quot;Example 2&quot;]
  }
  </code></pre>
  <p>I want the output to be the name of the files less the extension(.txt)</p>
  <pre><code>{
  &quot;test1&quot;: [
              &quot;example 1&quot;,
               &quot;Example 2&quot;
               ],
  
  &quot;test2&quot;: [
              &quot;example 1&quot;,
               &quot;Example 2&quot;
               ],
  
  &quot;test3&quot;: [
              &quot;example 1&quot;,
               &quot;Example 2&quot;]
  }
  </code></pre>
  <p>How do I go about doing this?</p>