se
unknown
plain_text
2 years ago
679 B
4
Indexable
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)Editor is loading...
Leave a Comment