Sometimes programming isn't fun. It isn't unusual to hit a section of code or hit an stage where you would rather do other things. However, that isn't just programming. It is anything that takes practice skill or dedication. It is a normal part of life. So it isn't so much motivation as dedication. You do it because you want to see things through not because it is fun.