次の手順があります。
def myProc(invIndex, keyWord):
D={}
for i in range(len(keyWord)):
if keyWord[i] in invIndex.keys():
D.update(invIndex[query[i]])
return D
しかし、次のエラーが発生します。
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence
D に要素が含まれている場合、エラーは発生しません。しかし、最初は D を空にする必要があります。