solution of think_python