Learning scientist Roger Schank has been a big proponent of the learn-by-doing approach to instruction. This theory proposes that learning is best achieved in the context of doing real, relevant tasks that matter. Learners don't have issues with transfer because they are exposed to problems in authentic environments. Learners who are learning by doing don't have troubles answering the question, "when or how can I use this knowledge?" Understanding the significance of the skill or knowledge learners are trying to acquire is evident in the context of the task they are attempting to perform. Here's more on the subject.
Do something you care about
This outstanding video by a YouTube vlogger Cheers, Kevin addresses the question of how one can learn to code. Like many technical skills, developing proficiency in any coding language is hard. In the video below, Kevin does an admiral job of providing recommendations to people interested in learning to code. His advice is pretty relevant for most skills. Do you have a hard skill you're interested in developing? Kevin's advice for learning the skill is spot on. Start with identifying something you are intensely interested in.