jfz-2023-s464983/TaskF05/run.py
2024-01-20 16:39:21 +01:00

18 lines
492 B
Python

import re
def replace(file_path):
word_pattern = r'\b\w+\b'
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
words = list(re.finditer(word_pattern, line))
if len(words) >= 3:
start, end = words[2].span()
word_length = end - start
line = line[:start] + 'x' * word_length + line[end:]
print(line, end='')
file_path = 'TaskF05/simple.in'
replace(file_path)