'I have not failed. I have just found out 99 whys that won't work.' This was rightly said by Thomas Edison. He invented the bulb on the 100th try.
'Try Try till you succeed' should be the motto when a task is at hand. There will be many barriers, brick walls. We have to cross these to get the treasure we deserve on the other side. These brick walls are for people who don't want the treasure badly enough or who are lilly-livered. They admit defeat and turn back. But a person who wants it badly will try innumerous methods to get past that wall. He will not stop till he crosses that wall.
While doing something, if you fail, start again. Try another method. Failure means that you are one step closer to success. You may encounter many defeats. But you should not be defeated. You should rise up from the ashes like a phoenix and try again.
A spider builds fragile webs and fails. Then he backtracks and starts again. To defeat failure, Perseverance is required.
After all, it is bad to fail, but worse to have have never tried to succeed at all.