input: Write a function to sort a list of dictionaries by a key in each dictionary. The function should take two parameters: the list of dictionaries and the key by which to sort the list. If the key is not present in any dictionary, it should handle the exception and return None.
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'age') == [{'name': 'John', 'age': 21}, {'name': 'Tom', 'age': 25}, {'name': 'Adam', 'age': 26}]
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'name') == [{'name': 'Adam', 'age': 26}, {'name': 'John', 'age': 21}, {'name': 'Tom', 'age': 25}]
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'height') == None
  assert sort_list_of_dicts_by_key([], 'age') == []
output: def sort_list_of_dicts_by_key(lst, key):
      try:
          return sorted(lst, key=lambda x: x[key])
      except KeyError:
          return None