Hi Lina<br><br><div class="gmail_quote">On 17 November 2011 14:04, lina <span dir="ltr"><<a href="mailto:lina.lastname@gmail.com">lina.lastname@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">>> Traceback (most recent call last):<br>
>> File "<pyshell#292>", line 1, in <module><br>
>> weight[list1[0]]=1<br>
>> TypeError: unhashable type: 'list'<br>
><br>
> You are trying to store a list as a key inside a dict. This cannot be done<br>
> because lists (like all mutable types) can't be hashed.<br>
<br>
</div>I checked online dictionary, still confused about hashed. is it equal<br>
to mix together or mess together?<br></blockquote><div><br></div></div>No.... you need to think programming/computer science where hash/hashing has a different meaning. See wikipedia:<br><a href="http://en.wikipedia.org/wiki/Hash_function">http://en.wikipedia.org/wiki/Hash_function</a><br>
<a href="http://en.wikipedia.org/wiki/Hash_table">http://en.wikipedia.org/wiki/Hash_table</a><br><br>Also see the description for "hashable" in the Python glossary: <br><a href="http://docs.python.org/glossary.html#hashable">http://docs.python.org/glossary.html#hashable</a><br>
<br>Basically hashing is a way to convert something (often a string) into an identifying number (not neccesarily but usually unique) in order to use this number as a token for the original thing. Aside, you can infer that that because the "dict" code complains about hashing implies that dicts themselves are essentially implemented as hash tables... ;) <br>
<br>HTH,<br><br>Walter<br><br><br>