input: Write a function to sort a list of dictionaries by a specified key in each dictionary. The function should return the sorted list. If the specified key is not present in the dictionaries, the function should raise a KeyError.
  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([], 'age')==[]
  try:
      sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'height')
      assert False
  except KeyError:
      assert True
output: def sort_list_of_dicts_by_key(lst, key):
      return sorted(lst, key=lambda x: x[key])