I'm trying to write a function with two input, word, and a dictionary. I already wrote a very inefficient version. The keys of the dictionary are letters with positive integers as keys. The function returns True if all letters in the word are in the dictionary and subtract one from the value every letter in the word from the dictionary or False if any of the letters in the word is not in the dictionary and will not change the value of the dictionary even if some of the letters are present. Here is my version
def isWordIn(word, store):
"""Input: word and store are strings and list respectively
Output: True or False
"""
for letter in word:
if letter not in store.keys():
return False
for letter in word:
if letter in store.keys():
store[letter] -= 1
return True