I have the following procedure:
def myProc(invIndex, keyWord):
D={}
for i in range(len(keyWord)):
if keyWord[i] in invIndex.keys():
D.update(invIndex[query[i]])
return D
But I am getting the following error:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence
I do not get any error if D contains elements. But I need D to be empty at the beginning.
{}
is a dictionary, not a set. – Sukrit Kalra Jul 7 '13 at 10:22D={}
you declare an empty dictionary, not a set. You declare an empty set byS=set()
. – Omar Tariq Nov 21 '16 at 8:04