"Learn by doing. Learn by doing." This line is from the pilot episode of Scrubs, and spoken by Turk to his best friend JD as he's trying to encourage JD to get over a mental block that is keeping him from doing his job. It still stands out to me to this day because right after that encouragement Turk sticks a needle in a patient and some bodily fluid comes squirting out causing a mess.
The lesson here is that you're going to make a mess while learning to code, and you're going to have to overcome that little voice in your head keeping you from making a mess. This is, personally, the only way I really learn something. You can repeat what the teacher has written on the chalkboard all day long, but true learning comes from failure.
You're learning a new language, and it's freaking awesome! Coding is akin to when you learned Spanish or French or what have you in school. It was considered an accomplishment when you could remember how to say "Where is the bathroom?" Do you recall how frustrating it was trying to remember tense, plural, etc.?
Frustrations are unavoidable. You will come across problems that leave you stumped and cause you to pull your hair out. It's just a fact. This is why it's so important to relish in the little victories! Take a moment to really take in your accomplishments, whether it's solving a problem or fixing a bug in your code. Remember that there was a time when you would look at code and see gibberish. Acknowledge your growth, and use that to foster further growth and development.