are you looking for something like a list comprehension or generator expression?
from typing import Iterator
def matching_keys(d: dict[tuple[int,int], int], n:int) -> Iterator[tuple[int,int]]:
return (
keypair
for keypair in d
if keypair[0] == n
)