Valid Parentheses Leetcode Solution Python