I seem to be encountering a problem and I think it is because I actually have my data as follows:<br><br>data = {1:[a,b,c], 2:[a,c], 3:[b,c], 4:[a,d]}<br><br>not as previously mentioned:<br><br>data = {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}
<br><br>So the values are actually stored as a list.<br><br>I am trying to adjust so that data ends up being:<br><br>{1:[1,2,3], 2:[1,3], 3:[2,3], 4:[1,d]}<br><br>right now I am getting:<br><br>{1:[[1],[2],[3]], 2:[[1],[3]], 3:[[2],[3]], 4:[[1],d]}
<br><br>which is problmatic for other things I am trying to do - it is indicating that the values are not hashable.<br><br><br><br><br><br><div><span class="gmail_quote">On 10/2/07, <b class="gmail_sendername">John Fouhy</b>
 &lt;<a href="mailto:john@fouhy.net">john@fouhy.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 02/10/2007, GTXY20 &lt;
<a href="mailto:gtxy20@gmail.com">gtxy20@gmail.com</a>&gt; wrote:<br>&gt; Hello all,<br>&gt;<br>&gt; Let&#39;s say I have the following dictionary:<br>&gt;<br>&gt; {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}<br>&gt;<br>&gt; I also have another dictionary for new value association:
<br>&gt;<br>&gt; {a:1, b:2, c:3}<br>&gt;<br>&gt; How should I approach if I want to modify the first dictionary to read:<br>&gt;<br>&gt;&nbsp;&nbsp;{1:(1,2,3), 2:(1,3), 3:(2,3), 4:(1,d)}<br>&gt;<br>&gt; There is the potential to have a value in the first dictionary that will not
<br>&gt; have an update key in the second dictionary hence in the above dictionary<br>&gt; for key=4 I still have d listed as a value.<br><br>You could use the map function...<br><br>Let&#39;s say we have something like:<br>
<br>transDict = { &#39;a&#39;:1, &#39;b&#39;:2, &#39;c&#39;:3 }<br><br>We could define a function that mirrors this:<br><br>def transFn(c):<br>&nbsp;&nbsp;&nbsp;&nbsp;try:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return transDict[c]<br>&nbsp;&nbsp;&nbsp;&nbsp;except KeyError:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return c
<br><br>Then if you have your data:<br><br>data = { 1:(&#39;a&#39;,&#39;b&#39;,&#39;c&#39;), 2:(&#39;a&#39;,&#39;c&#39;), 3:(&#39;b&#39;,&#39;c&#39;), 4:(&#39;a&#39;,&#39;d&#39;)}<br><br>You can translate it as:<br><br>for key in 
data.keys():<br>&nbsp;&nbsp;&nbsp;&nbsp;data[key] = map(transFn, data[key])<br><br>HTH!<br><br>--<br>John.<br></blockquote></div><br>