Longest Substring Leetcode Solution In Python List