My goal initially was just to learn to Python because I was asked to by my manager. I lost interest because I could complete exercises on the online course but didn’t have anything worth building or a reason to learn and apply my skills. A few months later I found an opportunity to automate fetching and processing of data and sending myself e-mail alerts. I looked up the pieces that I need to solve the immediate problem and then eventually went back to the online course to round off my knowledge with some structured learning to fill some gaps in basics I maybe didn’t realize.
Find a goal for projects to build. If the project seems to big and far away, break it up into pieces. Find some smaller projects. Chase these. Write them down. Think about them. Research. Talk to other people about them. Go for a run or walk away from technology and think about the what, why and how and who you are building it for - yourself, a company, the public?
You will have some quick successes and you will also get frustrated with doing something you thought would be easy but is taking longer than you thought or has no single “right” approach. So be patient and persistent.
If you find yourself doing small projects but not finishing them or feeling lost in the sea of web development / scraping / machine learning / automation / games and not getting anywhere… Choose some long term goals you can dream about like how to build a website for yourself / a friend / a business, or become a Backend developer or Data Scientist. These will help give you a reason and hunger to write code and learn and will also guide you on which parts of Python development to learn.