jezyki-formalne/TaskA04/task4.py

28 lines
594 B
Python
Raw Permalink Normal View History

with open('polish_wiki_excerpt.in', encoding='utf8') as f:
lines = f.readlines()
2024-11-14 20:46:13 +01:00
results = []
i = 0
for line in lines:
line = line.strip()
subdigits = []
pom = ''
for char in line:
2024-11-14 20:46:13 +01:00
if char in '0123456789':
pom += char
elif pom != '':
subdigits.append(pom)
pom = ''
else:
pass
if pom.isdigit():
subdigits.append(pom)
if len(subdigits) > 0:
finalLine = ' '.join(subdigits)
print(finalLine)