djfz-2023-s464986/TaskD04/run.py
Polevara Veronika 99d7880460 Zmiana D-Task
2023-12-10 17:37:17 +01:00

21 lines
498 B
Python

import re
import sys
def remove_non_digits(line):
return re.sub(r'[^0-9\s]', '', line)
processed_lines = []
for line in sys.stdin:
processed_line = remove_non_digits(line)
processed_line = re.sub(r'^\s+|\s+$', '', processed_line)
processed_line = re.sub(r'\s+', ' ', processed_line)
digit_groups = re.findall(r'\d+', processed_line)
if digit_groups:
processed_lines.append(' '.join(digit_groups))
print('\n'.join(processed_lines))