se

mail@pastecode.io avatar
unknown
plain_text
21 days ago
679 B
1
Indexable
Never
def find_consecutive_numbers(lst):
    consecutive_parties = []
    current_party = [lst[0]]

    for i in range(1, len(lst)):
        if lst[i] - lst[i-1] == 1:
            current_party.append(lst[i])
        else:
            if len(current_party) >= 2:
                consecutive_parties.append(current_party)
            current_party = [lst[i]]

    # Check the last party
    if len(current_party) >= 4:
        consecutive_parties.append(current_party)

    return consecutive_parties

# Пример использования
numbers = [122,168, 169, 170, 275, 292, 335, 360, 361, 378, 380]
result = find_consecutive_numbers(numbers)
print(result)
Leave a Comment