If you just need a solution, you can have a look at this page and that page, methods and algorithms whose name contain rk are the one to look at. But perhaps is your homework about implementing the method by yourself ? In this case, it is impossible to provide you a programming lecture on this website, so you should have a look at some Python tutorial about lists and loops, try to implement the method, and possibly come back with more precise questions about problems you encountered in your implementation.