def parse(lst, n):
    cluster = []
for i in lst:
    if len(cluster) <= 1:
        cluster.append(i)
continue
mean, stdev = stat(cluster)
if abs(mean - i) > n * stdev:
    yield cluster
cluster[:] = []
cluster.append(i)
yield cluster
How would you group/cluster these three areas in arrays in python?