I have a dictionary and a word:
check = {'a': 3, 'e': 1, 'p': 2, 'r': 1, 'u': 1, 't': 1}
word = 'rapturerererer'
I'm looking to run a test if all the letters from word
are in check
. So I need to keep a running count of all the used up letters and check if there are any negatives at the end.
I have code but it always caps out the values at 0 and never returns the negative values:
for letter in word:
if check.get(letter):
check[letter] -= 1
print(check)
{'a': 2, 'p': 1, 'r': 0, 'e': 0, 't': 0, 'u': 0}
What I'm expecting is this:
{'a': 2, 'p': 1, 'r': -5, 'e': -4, 't': 0, 'u': 0}
Can anyone explain why it's stopping at 0 for these values?