I would highly recommend against this.
If you lend money to someone, expect to never get it back ever, regardless of the deal you made. I know this from personal experience.
What I also know from personal experience is not to expect someone to learn how to code because you want them to. I gave my old laptop (which was still working well) to my cousin under the condition that he completed a single Udacity course on programming. I will tell you right now that he did not even come close to finishing the course.
I don't know you or your friend of course, but if I had to put my money on it, your friend is not going to learn to code, and you're not going to get your money back for a long time, if ever.