I have a dictionary as such:
d = {'a': 1, 'b': 2, 'c': 3}
I want to update the value of key 'c' and can do that with d['c'] = 30.
The behavior I want is to only be able to update existing keys, not add new keys. If I try to do d['e'] = 4 I would like it to throw some kind of exception instead of the default behavior which is to create a new key 'e' with value 4.
Is there a function that does such behavior? I know I can do a comprehension to first check if 'e' in d but again, checking if there's a built-in.