Conditional While Loop Python Problems Leetcode 150