finished python answer in two ways