for length in range(1, len(seq) / 2 + 1):
    valid_strings = {}
for start in range(0, len(seq) - length + 1):
    valid_strings[start] = tuple(seq[start:start + length])
candidates = set(valid_strings.values())
Finding patterns in list