Unable to update dictionary
<p>I am facing this problem while trying to code a Sudoku solver (with some parts referencing to <a href="http://norvig.com/sudoku.html" rel="nofollow">http://norvig.com/sudoku.html</a>)</p>

<p>Here's the code I have made so far with reference to the above URL.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>puzzle = '003198070890370600007004893030087009079000380508039040726940508905800000380756900'
cell = '123456789'
cell_break = ['123','456','789']


def generate_keys(A, B):
  "Cross product of elements in A and elements in B."
  return [a+b for a in A for b in B]

#print generate_keys(cell,cell)

def dict_puzzle(puzzle,cell):
  'Making a dictionary to store the key and values of the puzzle'
  trans_puzzle = {}
  key_list = generate_keys(cell,cell)
  i=0
  for x in puzzle:
    trans_puzzle[str(key_list[i])] = x
    i = i + 1
    return trans_puzzle

dict_puzzle(puzzle,cell)['11'] = 'die'
print dict_puzzle(puzzle,cell)['11']</code></pre>
</div>
</div>
</p>

<p>for the last 2 lines of the code, I tried to mutate the dictionary but to no avail. It just returns me 0, which is the original value. (i.e the mutation wasnt successful)</p>

<p>I am not sure why is this happening :(</p>

<p>You're calling the function again, so it returns a new dictionary. You need to assign the result of the first call to a variable and mutate that.</p>

<pre><code>result = dict_puzzle(puzzle,cell)
result['11'] = 'die'
print(result)
</code></pre>

python dictionary