Have a look at:-
Frustration - the first time you can't do it the second time.
Desperation - the second time you can't do it the first time
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.