Inserting variables into a dictionary in Python
<p>Why is this code adding the key but not the value for a dictionary in Python?</p>

<p>Here is the result:</p>

<pre><code>$ python hashtest.py
set(['yes:no'])
set(['hi', 'yes:no'])
</code></pre>

<p>And the code is as follows:</p>

<pre><code>hashmap={"yes:no"}

print hashmap
var1="hi"
var2="bye"

#hashmap[var1]=var2
#print hashmap

hashmap.update({var1:var2})
print hashmap
</code></pre>

<p>The first method (<code>hashmap[var1] = var2</code>) gave a type error (assignment).</p>

<p>TIA</p>