title: How can I save the value of a variable in a list but not the variable itself?
body: <p>My problem is that when I append a variable to a list in python, it saves the pointer to the value in the list and not the value itself. This means that when I change the variable that I appended to the list, the value in the list changes as well which I don't want. I want to save the current value of the variable in the moment I append it to the list, and that shall not change anymore after the appending.</p>
  <p>Here is the code, I hope I could make myself clear:</p>
  <pre><code>while j &lt; n:
      if first_graph[j] == (n-1):
          while first_graph[j] == (n-1) and j &lt; n-1:
              j += 1
          if first_graph[j] == (n-1) and j == n-1:
              j += 1
          else:
              first_graph[j] += 1
              for i in range(j):
                  first_graph[i] = 0
              all_graphs.append(first_graph)
              j = 0
      else:
          first_graph[j] += 1
          all_graphs.append(first_graph)
  </code></pre>
  <p>This is obviously not all of it, but my problem is that the <code>first_graph</code> in the <code>all_graphs</code> list gets updated when it changes, so in the end <code>all_graphs</code> is just filled with the same list several times</p>