So how do we build mental strength to be like that?
The answer is simple : consistency.
Basically master it.
And to master it one must do it everyday, all the time.
Create targets and work on them everyday until it is done.
That will make you never give up.
And abandoning perfection in the process is crucial.
Think about small steps.
Some days you will wake up tired and unmotivated and that is normal, you are human.
Then, even tired and unmotivated, do something towards your targets.
Day in, day out, work on it.
Then success is a consequence.
To endure something is to keep your head up, and never give up.