title: Storing the values in list Python
body: <p>In my below program I have used the append() function to store the entropy in a list.
  I have 36 dialogs in the program and I want to store the entropy of one dialogue into the list and then update the values in the same variable for the second dialogues and for third dialogue entropy also update the values in the same list. </p>
  
  <p>But append() function will append all the entropies for all the dialogues in the list but not updating the values. </p>
  
  <p>My Program is below : </p>
  
  <pre><code>import numpy as np
  import csv
  from scipy.stats import entropy
  from math import log10
  import statistics
  import matplotlib.pyplot as plt
  
  
  store_entropy = []
  critical_entropy = 0
  position = 0
  outputfile = open("Output.txt","w")
  with open('data.csv', 'r') as file:
      reader = csv.reader(file)
      for line in reader:
          lines = filter(None, line[2:])
          lines1 = ' '.join(lines).split(',')
  
          for row in lines1[::]:
              makeOneLine = row.rstrip('\n')
              delimiter = " "
              makeOneLine = delimiter.join(makeOneLine.split(delimiter, 3))
              numpyArraysDisplay = np.array(list(makeOneLine.split(" ")))
              print(numpyArraysDisplay)
              outputfile.write(str(numpyArraysDisplay) + '\n')
  
          #Loop for first segment
              for x in range(0, numpyArraysDisplay.size):
                  part1 = numpyArraysDisplay[:x + 1]  # First segment divide
                  strings, counts = np.unique(part1, return_counts=True)
                  CountWordsfrequency = np.array(list(dict(zip(strings, counts)).values()))
                  print(CountWordsfrequency)
                  outputfile.write(str(CountWordsfrequency) + '\n')
  
                  for y in range(0, CountWordsfrequency.size):
                      probability = CountWordsfrequency[y]/ part1.size
                      outputfile.write("Probability is \t" + str(probability) + '\n')
              ent2 = entropy(counts,base=10)
              outputfile.write("Entropy is \t" + str(ent2) + '\n')
              store_entropy.append(ent2)
  </code></pre>
  
  <p>If I print <code>store_entropy</code> list then it will print all the values in the list from first dialogue to last. I want that first dialogue entropy store in variable and when loop run second time second dialogue entropy updates the first one not append it.</p>
  
  <p>My output is :</p>
  
  <pre><code>[0.0, 0.30102999566398114, 0.4771212547196623, 0.4515449934959717,0.0,0.6179053239112496, 
   0.6135103844338377, 0.6097931356022916]
  </code></pre>
  
  <p>Expected is:</p>
  
  <pre><code>[0.0, 0.30102999566398114, 0.4771212547196623, 0.4515449934959717]
  [0.0, 0.6179053239112496,0.6135103844338377, 0.6097931356022916]
  </code></pre>
  
  <p>Please tell me if anyone has solution. </p>