def consecutive_groups(iterable):
    s = tuple(iterable)
seen = set()
for size in range(1, len(s) + 1):
    for index in range(len(s) + 1 - size):
        slc = iterable[index:index + size]
if slc not in seen:
    seen.add(slc)
yield slc
Substrings of a string using Python