This goes for learning anything - not just coding - but, focus on something that interests you. If you stopped halfway through because you found algorithms difficult or boring… do something else, learn about css or html, see something cool on a webpage? try and replicate it, or something similar. If you’re not interested and engaged you won’t learn effectively.
It’s not your discipline that’s the problem, if it is enjoyable you’ll want to do it. Don’t take it too seriously and sit for long periods, be curious and learn what interests you. Try to build a habit of just coding for 10 minutes a day or whatever works for you, then it just becomes part of what you do and you don’t have to rely on something as fickle as discipline.
Your future starts today, you can either focus on your goal and learn a bit more and get a bit better or spend your time on other things, it is up to you, and you get to make that choice each day. Learning to code is a marathon, not a sprint. You always feel like a beginner at times (at least I do), but it does get easier.
Best of luck.