You will start to appreciate the effort and enjoy it as it leads you to your goal. The failures you will see as steps to reaching the achievement of your goal.
Think about a person who you admire.
Do you think he or she was gifted or worked hard to be a person or to do something you admire? Find out the truth. If by a huge effort, then admire that person more.
Think about a situation when someone outdid you and you thought that was because they were smarter or more gifted.
Now think how much effort they had to put in that, maybe used different strategies, spent more time. You also could get to this point. You are able to do it if you really want to.
Think about a situation when you felt stupid.
Next time it happens again, think what you can learn from it, without judgment. And if it is possible, do it again with new knowledge