How do you actually finish an online course?
The short answer
Schedule fixed learning slots in your calendar (two or three short sessions a week), tie the course to a concrete goal with a deadline, and make it social. Tell someone what you are learning or find a learning buddy. Motivation follows rhythm, not the other way around.
In detail
It is the open secret of online learning. Most started courses are never finished. Not because people are lazy, but because a course without a schedule, classmates, or deadlines runs entirely on self-discipline. That is fixable with structure.
The calendar approach works best. Block fixed slots (Tuesday evening, Saturday morning) and treat them as appointments. Short, regular sessions beat binges, since twice a week for 45 minutes keeps the material warm, while a lost month means starting over. Platforms help. DataCamp and Brilliant are built around short daily practice, and streaks turn out to be surprisingly motivating.
Make it concrete and social too. A goal like "my first Python project live in March" pulls harder than "learn to code someday". Tell a colleague or partner what you are working on, or better, agree on what you will demo. And pick courses with projects, because building something gives the satisfaction that watching never will.