input: Write a function to compare two dictionaries and return a new dictionary containing the keys that are present in both dictionaries.
  assert compare_dicts({'a': 1, 'b': 2, 'c': 3}, {'b': 4, 'c': 5, 'd': 6}) == {'b': 2, 'c': 3}
  assert compare_dicts({'x': 10, 'y': 20, 'z': 30}, {'y': 25, 'z': 35, 'a': 40}) == {'y': 20, 'z': 30}
  assert compare_dicts({'m': 100, 'n': 200}, {'o': 300, 'p': 400}) == {}
output: def compare_dicts(dict1, dict2):
      return {k: dict1[k] for k in dict1 if k in dict2}