I have this dictionary:
d = {'a': (1, 2, 'a'), 'b': (1, 2, 'b'), 'c': (2, 4, 'c'), 'd': (1, 3, 'd'), 'e': (0, 1, 'e'), 'f': (0, 1, 'f'), 'g': (1, 3, 'g'), 'h': (0, 1, 'h'), 'j': (1, 2, 'j'), 'i': (0, 1, 'i'), 'k': (-1, 0, 'k')}
How can I subtract the value by 1 for a specific key/value pair in this dictionary if the key matches the parameter?
For example, I want to subtract the values of key a by 1, so that it now displays:
{'a': (0, 1, 'a')
How can I edit the values of that specific key and decrease only the integers by 1 while creating the same dictionary again?
Code so far:
def matching(key_to_subtract):
for key, value in d.items():
if key_to_subtract == key:
matching("a")
Desired Output:
{'a': (0, 1, 'a'), 'b': (1, 2, 'b'), 'c': (2, 4, 'c'), 'd': (1, 3, 'd'), 'e': (0, 1, 'e'), 'f': (0, 1, 'f'), 'g': (1, 3, 'g'), 'h': (0, 1, 'h'), 'j': (1, 2, 'j'), 'i': (0, 1, 'i'), 'k': (-1, 0, 'k')}