input: Write a function in Python that takes a list of objects and a string representing an attribute and returns a list of those objects sorted by that attribute. If the attribute is not found in any of the objects, raise a ValueError.
  
  def sort_by_attr(objects, attr):
   if any(attr not in obj for obj in objects):
   raise ValueError("Attribute not found in one or more objects")
   return sorted(objects, key=lambda item: item[attr])
   
  assert sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "age")==[{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}],"Attribute not found in one or more objects"
  assert sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "name")==[{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}],"Attribute not found in one or more objects"
  assert sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "height")==ValueError, "Attribute not found in one or more objects"
output: def sort_by_attr(objects, attr):
      if any(attr not in obj for obj in objects):
          raise ValueError("Attribute not found in one or more objects")
      return sorted(objects, key=lambda item: item[attr])