I have a python dictionary consisting of key value pairs. What I want to do is delete items who’s keys are a certain format. In my case format of the keys I want to delete are: Letter, number, number. Example: A12, A56, A32
So in the below case I want to delete all the items that consist of an Axx (where the x’s are numbers).
{'A34': 83, 'B32': 70, 'A44': 66, A12: 47, 'B90': 71}
I know that the format can be targeted using regex. For example the following code will count the number of keys that have the Axx format (where x’s are numbers)
print(sum(1 for k in d.keys() if re.match('^A\\d{2}$', k)))
But how can I change this around so that it can delete the item of the dictionary whos key Is of the Axx format.