You use lesson to refer to an experience which acts as a warning to you or an example from which you should learn.
教训
If you say that you are going to teach someone a lesson, you mean that you are going to punish them for something that they have done so that they do not do it again.
给某人一个教训