It sad that it has come to this, but your approach is correct - it is the act of writing (code or prose) that is important, not the finished output itself.
Interestingly, this applies not just for learning, but also to a great extent in production/work contexts too.