There are many paths to learn to code, and everyone's journey will be unique. I taught myself for several years, and then attended a coding bootcamp, Prime Digital Academy in Minneapolis, Minnesota.
Prime's slogan is "Code Tomorrow," and it has a double meaning. First, it means, "learn to code, starting tomorrow." Second, it means "Code the Future." I love that second meaning. That's the real motivation for learning to code, to play a role in the progress of humankind.
You Can Do It, It's Just a Question of How
This is the first and most important lesson in learning to code (and learning anything, for that matter), just believe that you can. There are so many resources, online and off, free and paid.
But once you decide you're ready to learn, make a plan. You have lots of options. Should I go back to school, sign up for online courses, watch Youtube videos, read books and work through examples, apply to a coding bootcamp?
To answer these questions, I think it's helpful to think about what you need to achieve your goal. And to realize that even if you don't have everything you think you need, you probably have more than you realize, and enough to succeed.
Make A Plan
What languages should I learn? What books should I read? What videos should I watch? In general, how should I spend my time? If you go to a bootcamp, this question will be answered for you. At the one I attended, we had to learn the "MEAN" Stack (MongoDB, Express, Angular and Node.js). We had a curriculum and structure--everything was mapped out, and that can be very helpful.
But you can create your own plan by using free resources.
One great resource is FreeCodeCamp--even if you don't sign up, you can click on their "MAP" link and take a look at the plan they've put together. But think about signing up--it's completely free.
Check out some local Meetups (find them on Meetup.com), and talk to software or web developers, ask them for advice. There are Meetups for all kinds of different languages and technologies, big groups and small. And all the ones I've been to have been pretty friendly, so find one you like.
Podcasts. Just do a search for podcasts about programming, web development, or learning to code.
MOOC's (Massive Open Online Courses) There are too many of these to list here. Just do some searching. Some used to be free, but aren't anymore; some aren't free, but are pretty cheap. Make sure you read reviews (not just of the courses, but the platforms, also).
Other Sites with courses. I use Lynda.com because where I live in Minnesota, I can get free access with my library card number--check with your local library. I've never personally used Khan Academy, but I've heard lots of great things. And finally, there's Youtube. The biggest challenge with Youtube is finding the best content.
Finally, you could, especially if you're very motivated and independent, decide that your "plan" will be to just sit down every day for a certain number of minutes, and learn something that interests you. This approach might take more time, especially if you skip around from topic to topic, but it might also be the most rewarding for you personally.
Set Deadlines
For me, this was one of the major benefits of going to a bootcamp, but again, if you are motivated, you can set your own deadlines.
Or you can get creative. Maybe work with a friend, and keep each other accountable. Or give yourself rewards (or punishments(?), whatever works for you) to get things done.
This might seem like it's not essential, but at least practice setting deadlines, and pay attention to how much you accomplish with and without them.