Advice for Learning to Program
Remember, you are smart and you already know a lot in life. Having code that doesn't work is a frequent but temporary condition of being a programmer. You have what it takes to figure things out.
It is tough to focus when you are stressed out. It could be the challenge of learning to program, other life stresses, or a combination. When we are stressed, blood shifts out of our frontal cortex (the part of the brain needed for higher reasoning) and into more basic functions. Dr. Daniel Siegel explains: Hand Model of the Brain
It takes some skill and practice to get that blood back into our frontal cortex.
I recommend that as soon as you start to get frustrated, get up, go away from the computer, take some deep breaths, and do some jumping jacks or walk around the block. Walking is especially good because the coordination of your left arm with your right leg and vice versa helps to balance the sides of your brain.
After a 5min or so break, come back and carefully read the error message again. Most tools these days give detailed error messages. You can develop the skill to understand those messages, even if they look confusing to begin with.
It also helps to talk through the problem, even if the person you are talking to does not know about programming. It even helps to describe the problem to a pet or a stuffed animal. The very act of talking out loud about what is happening activates different parts of your brain than just thinking about it.
Programming is a skill that is learned through practice. It is not an inborn ability that some have and others do not. Like any skill, some people will advance more quickly and some people will eventually reach a higher level than others, but nearly everyone can become proficient at a basic level. If you keep practicing, you will definitely get better at programming, and someday you may become great. If you look at others and are awed by their skill, ask them about how they learned. Chances are, they have practiced a lot.