I have taken computer programming courses before (in programming theory and also in languages such as FORTRAN and assembler language), and I have worked as a computer programmer, so I have had experience in writing, testing, and modifying code.
I’ve found that a flexible attitude (or what author Carol S. Dweck calls a “growth mindset” in her book, Mindset) is an asset in learning and applying coding skills. My experience is that code that reads well does not always perform well; it does not always perform as expected. When that happens, I don’t take it personally or as a failure on my part; I simply go back to the code and see what sort of adjustments need to be made.
This is not to say that the experience is not extremely frustrating; it is. Looking at a section of code for what seems to be hours for a missing parenthesis or misplaced semicolon can be aggravating. Not getting the expected result can be discouraging. This is pretty much inevitable when taking a programming class. When that happens, my plan is to pause, reflect, take a breath, analyze the problem, and where needed, get other ideas on what might be causing the difficulty.
Most of all, I’ve found that, eventually, I can get the code to do what it needs to do. It just takes time, patience, and flexibility.