chalk something up to experience

Verb

 * 1)  To take a lesson from a bad outcome instead of grieving it.

Usage notes
The verbs and  are used to indicate that the object causes the subject. In this idiom, however, the object is caused by the subject. That is, the bad outcome has led the person in question to gain experience.