Cities of the second class and villages may contract with a person including such person's parent or guardian if such person is a minor to loan money to such person while such person pursues a course of study at an accredited college or university leading to a degree of Doctor of Medicine or Doctor of Dental Surgery in consideration for such person's promise to practice medicine or dentistry in such city or village and repay such city or village for such money loaned during such person's study after such person shall have become established in his or her practice, and upon such other terms and conditions as the city council or village board of trustees may determine are warranted in the premises. If such person shall discontinue his or her course of study before attaining such degree or fail to practice in such city or village after attaining such degree and a license to practice medicine or dentistry, such city or village may pursue any remedy it may have against such person or his or her parent or guardian as in any other commercial transaction.