title: variable changing despite of copy
body: <p>I've written code for a sudoku-solver and chase the bugs right now. There is a function "insert" that should copy the dictionary "mglwerte" and change it. But the function changes not only the copy but the original dictionary, despite using copy at the beginning of the function. Here is the call of the function:</p>
  
  <pre><code>    print(ebene, ": 748: ", mglwerte["748"], " / 779: ", mglwerte["779"])
      sudokuneu, mglwerteneu, geklappt = insert(int(var[0]), int(var[1]), wert, sudoku, mglwerte)
      print(ebene, ": 748: ", mglwerte["748"], " / 779: ", mglwerte["779"])
  </code></pre>
  
  <p>And the function itself:</p>
  
  <pre><code>def insert(z,s,v,sudokualt,mglwertealt):
      sudoku = sudokualt.copy()
      mglwerte = mglwertealt.copy()
      geschafft = True
      q = 3*int((z-1)/3) + int((s-1)/3) + 1
      keyfull = str(z) + str(s) + str(q)
  
      if v not in mglwerte[keyfull]:
          print(v, "not in ", keyfull)
          return None, None, False
  
      sudoku[keyfull] = v
      mglwerte[keyfull] = {}    
  
      for key,value in mglwerte.items():
          if len(value) &gt; 0:
              if str(key[0]) == str(z) or str(key[1]) == str(s) or str(key[2]) == str(q):
                  value.discard(v)
                  mglwerte[key] = value
                  if len(value) &lt; 1:
                      geschafft = False
      return sudoku, mglwerte, geschafft
  </code></pre>
  
  <p>The print-statements in the first piece of code show me, that "mglwerte" is changed after the call of the function. How can I change this? </p>