お世話になります。
今辞書についてのコードの記述の部分を勉強しています。
書籍での学習です。
def say_hello():
... print('Hello!')
...
a = {say_hello: 'This is a function.'}
a[say_hello]
'This is a function.'
a = {'call function test': say_hello}
a['call function test'] ()
Hello!"
'call function test' in a('call function test')
TRUE →Trueでなければいけないのに下記のエラーがでるのはなぜですか?
(Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'dict' object is not callable)
del a['call function test']
a
{}
どのように書き換えればよいのでしょうか?
ご教授ください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/09 03:49