My grandfather once wrote about a friend of his, who on his deathbed reflected that he’d failed at everything he’d ever put his hand to. My grandfather also wrote that he’d failed a lot, but he didn’t fall into the trap of thinking himself a failure.
There’s a huge difference between failing often and being a failure.
Failing means you try things and they don’t work out. Being a failure means you’ve given up trying.
Failing means you get to learn something. Being a failure means you’ve stopped learning.
The more you try and fail, and learn and try again, the more you build your odds of success.
When I’m attempting something new with coding, something I haven’t done before, it’s not unusual for me to go through a couple dozen different attempts that don’t work before finding the thing that does. Sometimes it takes a lot more than that. Each failed attempt provides another clue to the puzzle, until finally the solution becomes clear.
Strangely enough, it’s on the days when I’ve failed most often, I find that by the end of the day I’m most energized. Those are the days that I look back on and see that I’ve gotten the most accomplished.