Temporary defeat is going to happen, over and over again, so it’s best that you learn to deal with it. Most people would rather not deal with it and simply quit. They might have been persistent to some degree in the past but as they faced more and more setbacks, what was required to make them quit got smaller and smaller.
It gets to the point where just one setback can cause a person to give up on their goal. Can quitting become a habit? If you quit often enough, yes. This means that perseverance can also become a habit.
If you push through enough obstacles, when faced with yet another one, you’re going to automatically push through that one as well. If you stop and retreat every time things get tough, when things get tough, you’ll almost automatically retreat.