This means that in a given situation they try out variations of action or different actions. Then they note the effect. If the action was beneficial, if it brought the animal nearer its objective , its brain stores the experience . We feel pleasure when we have solved a difficult puzzle, when we have done a difficult task well. Many people feel pleasure when they learn that dinner is ready, even before they have had the chance to eat anything.
Humans learn much better than animals.
They are better at extracting those elements from a situation, that are necessary for an action to be applicable. Again, between humans, there is an appreciable variation in this ability to learn. Humans learn faster at 20 years of age than at 60. Some have mental problems and can learn only very slowly and only simple relationships. So we see, the ability to learn has a wide range, from some rather stupid animals to some rather bright humans.