I'm learning python and in need of some tips working with dictionaries. Please see code below. I've tried using if word in filename.values()
and if filename[word]
to check if the word exists inside the dictionary but it's not working. I want to check and if possible count the total number of times word appears inside of those lists inside the dictionary. Please advise!
files = {"f1": ["cat", "dog", "mouse"],
"f2": ["rat", "elephant", "tiger"]}
word = "dog"
for filename in files:
if word in filename.values():
print(True)
else:
print(False)