Algorithm For Pyhton Example