Persevere
Keep at it. One method that may help is to start with some sample code that works, then add one feature and get that to work. Take a snapshot, then add another feature. Repeat until done, or until you're dead.
The approach in the above paragraph is the opposite of the other approach recommended in the earlier replies, which was to learn the theory and concepts and then apply them. The "First understand theory, then apply it" approach is the gold standard in academia and almost everyone swears by it.
My approach takes the reverse path. It's more of an apprentice approach - watch someone who can program, mimic what they do, and pick up the theory as it comes.