finished python version of program