title: Create and append text file using python dictionary
body: <p>In the initial stage, I tried the following code. This code I used to create text file using the python</p>
  <pre><code>import json
  final_key = [&quot;letters&quot;, &quot;words&quot;, &quot;score&quot;]
  final_list = []
  letters_1=['U', 'I', 'J', 'T', 'D', 'F', 'S', 'H', 'J']
  final_list.append(letters_1)
  word=['U', 'T', 'S']
  final_list.append(word)
  score = 3
  final_list.append(score)
  res = {}
  for key in final_key:
      for value in final_list:
          res[key] = value
          final_list.remove(value)
          break
  with open('log.txt', 'w') as convert_file:
       convert_file.write(json.dumps(res))
  final_list_1=[]
  letters_2=['A', 'P', 'J', 'P', 'F', 'F', 'L', 'H', 'P']
  final_list_1.append(letters_2)
  word_1=['L', 'V', 'S','G']
  final_list_1.append(word_1)
  score_1 = 10
  final_list_1.append(score_1)
  res_1 = {}
  for key in final_key:
      for value in final_list_1:
          res_1[key] = value
          final_list_1.remove(value)
          break
  with open('log.txt', 'a') as convert_file:
       convert_file.write(json.dumps(res_1)) 
  </code></pre>
  <p>my result</p>
  <pre><code>{&quot;letters&quot;: [&quot;U&quot;, &quot;I&quot;, &quot;J&quot;, &quot;T&quot;, &quot;D&quot;, &quot;F&quot;, &quot;S&quot;, &quot;H&quot;, &quot;J&quot;], &quot;words&quot;: [&quot;U&quot;, &quot;T&quot;, &quot;S&quot;], &quot;score&quot;: 3}
  {&quot;letters&quot;: [&quot;A&quot;, &quot;P&quot;, &quot;J&quot;, &quot;P&quot;, &quot;F&quot;, &quot;F&quot;, &quot;L&quot;, &quot;H&quot;, &quot;P&quot;], &quot;words&quot;: [&quot;L&quot;, &quot;V&quot;, &quot;S&quot;, &quot;G&quot;], &quot;score&quot;: 10}
  </code></pre>
  <p>Now, I want to create that text file with the following output</p>
  <pre><code>{
  &quot;log&quot;: [
          {
            &quot;letters&quot;: [&quot;U&quot;, &quot;I&quot;, &quot;J&quot;, &quot;T&quot;, &quot;D&quot;, &quot;F&quot;, &quot;S&quot;, &quot;H&quot;, &quot;J&quot;], 
            &quot;words&quot;: [&quot;U&quot;, &quot;T&quot;, &quot;S&quot;], 
            &quot;score&quot;: 3
          },
          {
            &quot;letters&quot;: [&quot;A&quot;, &quot;P&quot;, &quot;J&quot;, &quot;P&quot;, &quot;F&quot;, &quot;F&quot;, &quot;L&quot;, &quot;H&quot;, &quot;P&quot;], 
            &quot;words&quot;: [&quot;L&quot;, &quot;V&quot;, &quot;S&quot;, &quot;G&quot;], 
            &quot;score&quot;: 10
          }
          ]
  }
  </code></pre>
  <p>How can I change the code to achieve above task</p>
  <p>Thank you !!!</p>