solution of the think python