Yes, you can earn money while learning. You can earn few bucks for creating websites in HTML, CSS, and some javascript that every beginner programmer knows, and it is easy to learn and code.