You could start by writing a pseudo code, and then fill it in. I have seen Alan (CAB) post this method plenty of times to people who want to learn to write code.
You first need to select the polyline, then you need to ask for the distance you want to divide it, then the code should do the rest.
I have one that I wrote the does almost what you want, but I want you to try to write your own code first instead of people just supplying you with working code, or you won't learn.