How do you retain what you learn in programming books

I've been reading no starch press Python Crash Course and I've been enjoying the book. It had it's own challenges and I think the book does a great job teaching Python fundamentals through projects and chapters based on topics such as OOP, Loops, and many more.

Though I have a hard time retaining what I learn from reading that book. I understand the code when I read it but then when I try it for myself I can't really retain it. If it is from a lack of practice, what are some ways that I can practice my code over and over again to get better.

Also what next steps would you recommend after reading this book? My budget is tight so I'm thinking about watching videos on YouTube.