<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_ligands(self, solvent=True):
 """Retrieves all ligands from the `Assembly`. Parameters solvent : bool, optional If `True`, solvent molecules will be included. """

        if solvent:
            ligand_list = [x for x in self.get_monomers()
                           if isinstance(x, Ligand)]
        else:
            ligand_list = [x for x in self.get_monomers() if isinstance(
                x, Ligand) and not x.is_solvent]
        return LigandGroup(monomers=ligand_list)