Prawie skończyłem lekcje.

I thought that homework was ‘praca domowa’? Can lekcje (lekcja) also mean homework, as well as lesson?

Yes! “Lekcje” generally means “lessons”, but it is also often used as another word for “praca domowa” (homework).

“Praca domowa” feels more formal. When a teacher sets homework for their class, they will almost always call it “praca domowa”, and not “lekcje”.

“Lekcje” is chiefly used by children (and their parents), especially in phrases such as “odrabiać lekcje” (do one’s homework). So it’s also influenced by collocations with verbs. Personally, my intuition is usually to say “zadawać pracę domową” (set homework), but “odrabiać lekcje” (do homework).