Python Loop Some Coding Questions Leetcode Problem 531390