/
biggor
/
Python_for_Data_Science
Обзор
Документация
Войти
/
biggor
/
Python_for_Data_Science
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
10.11.py
32 строки
858 B
biggor
upload files
19 ноя 2025, 23:34
19 ноя 2025, 23:34
74ee117
Код
Авторство
О чём код?
import re result = [] s = input() allowed_chars = '0123456789.' splited_s = re.split("[^{}]+".format(allowed_chars), s) filtered_s = [x for x in splited_s if x != '' and not (len(x) > 1 and x.count('.') == len(x))] for item in filtered_s: dot_amount = item.count('.') if dot_amount == 0 or dot_amount == 1: result.append(item) else: parts = item.split('.') i = 0 while i < len(parts): if i + 1 < len(parts): pair = parts[i] + '.' + parts[i + 1] result.append(pair) i += 2 else: result.append(parts[i]) i += 1 for idx in range(len(result)): stripped = result[idx].strip('.') result[idx] = stripped result = [x for x in result if x != '' and x != '.'] print(result)