learn your lesson
US /lɜrn jʊər ˈlɛsən/
UK /lɜrn jʊər ˈlɛsən/

1.
to suffer a bad experience and understand from it not to do the same thing again
:
•
After losing all his money, he finally learned his lesson about gambling.
•
If you don't study, you'll fail the exam and learn your lesson the hard way.