Python 列表中的序列数

Python 列表中的序列数,python,sequence,Python,Sequence,我需要确定整数列表中的序列。如果列表中的成员在65范围内,则该成员可以是序列的一部分。所以在我的名单上 43 83 90 250 265 500 43,83,90都是1序列中的成员,它们都在65的范围内。此外,250265构成1个序列。现在,我的代码从列表中创建元组。(43,83)(83,90)但它不知道它们都是同一序列的一部分 while count < len(w_seq_list)-1: if((w_seq_list[count+1] > w_seq_list[count]

我需要确定整数列表中的序列。如果列表中的成员在65范围内,则该成员可以是序列的一部分。所以在我的名单上

43
83
90
250
265
500
43,83,90都是1序列中的成员,它们都在65的范围内。此外,250265构成1个序列。现在,我的代码从列表中创建元组。(43,83)(83,90)但它不知道它们都是同一序列的一部分

while count < len(w_seq_list)-1:
 if((w_seq_list[count+1] > w_seq_list[count]) and ((w_seq_list[count+1] - w_seq_list[count]) <= 65)):

     wr.append((w_seq_list[count],w_seq_list[count+1])) // add tuple to sequence list
     count += 1
 else:
     count += 1
     continue
while count如果((w_-seq-list[count+1]>w_-seq-list[count+1]-w_-seq-list[count])和((w_-seq-list[count]),如果你有
15,43,83,90
,那会是一个序列吗?还是会有两个序列:
15,43
43,83,90
?它必须是2.(90-15)>65和(83-15)>65,但为什么43会与83分开呢?
def grouper(my_list):
    previous, temp, result = my_list[0], [my_list[0]], []
    for number in my_list[1:]:
        if number - previous > 65:
            result.append(temp)
            temp, previous = [number], number
        else:
            temp.append(number)
    if temp:
        result.append(temp)
    return result

assert(grouper([43, 83, 90, 250, 265, 500]) == [[43, 83, 90], [250, 265], [500]])
assert(grouper([15, 43, 83, 90]) == [[15, 43], [83, 90]])