Hello i have a list of words that I want to check against a dictionary with keys and values. Actually I just want to know if some of the words in the list appear in the values of the dictionary. This is probably a ver easy task in python, but I am a beginner and I just keep getting the same error that I obviously don't understand.
Here is my code (the dict is at hand ):
words = ["give", "a", "pearl", "to", "the" "elephant"]
for k, v in dic.items():
for word in words:
if word in v:
print(v)
or alternatively:
relevant = {d:reldic[d] for d in reldic if words in reldic[d]}
print(relevant)
the error I get:
TypeError: unhashable type: 'list'
What is missing?
Thanks in advance!
Update:
Ok, this help to understand the question better. That how my data looks like:
2000/9/1 abe D mes Español inan.|m.|m.
2000/9/1 abe D luna Español inan.|m.|m.
2000/9/1 abe D sol Español inan.|m.|m.
2000/9/2 gacuri D meter Español v.t.
2000/9/2 acuri D meter Español v.t.
2000/9/2 yacuri D meter Español v.t.
Then I have a collection of relevant blocks:
dic = collections.defaultdict(set)
for e in entries:
dic[e[1]].add(e[3])
and lastly my dictionary:
reldic = {d:dic[d] for d in dic if len(dic[d]) > 1}