Skip to content

Instantly share code, notes, and snippets.

@0xBADDCAFE
Last active December 19, 2015 06:19
Show Gist options
  • Save 0xBADDCAFE/5910955 to your computer and use it in GitHub Desktop.
Save 0xBADDCAFE/5910955 to your computer and use it in GitHub Desktop.
computer_science room #Lingr
'''
[_] 0286 s_of_p 6 hours ago chap2を読んで試して考えよ: dictのkeyにlistを用いると何が起こるのか? (by bgnori)
'''
Python 3.3.2 (default, Jul 2 2013, 19:41:05)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a_dict={'a':1, 'b':2, 'c':3}
>>> a_dict
{'a': 1, 'b': 2, 'c': 3}
>>> a_dict['append']=4
>>> a_dict
{'a': 1, 'b': 2, 'c': 3, 'append': 4}
>>> a_dict[[1,2,3]]='todo 286'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> a_dict={[1,2,3]:'test'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> a_dict={'todo286':'test'}
>>> a_dict
{'todo286': 'test'}
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment