jfz-2023-s473579/TaskA04/run.py

45 lines
1.3 KiB
Python
Raw Normal View History

2023-10-29 08:51:31 +01:00
def checkNumber(i):
if (i == '0'
or i == '1'
or i == '2'
or i == '3'
or i == '4'
or i == '5'
or i == '6'
or i == '7'
or i == '8'
or i == '9'):
return i
else:
return None
def openFile(fileName):
with open(fileName, "r", encoding="utf-8") as file:
for row in file:
lastCharacter = ''
checkWord =''
for i in row:
if i == checkNumber(i):
if lastCharacter != checkNumber(lastCharacter):
checkWord += ' '
checkWord += i
else:
checkWord += i
if i == '\n':
if checkWord != '':
print(checkWord)
checkWord = ''
lastCharacter = i
print('---------------------SHAKESPEARE.EXP--------------------------------------')
openFile('polish_wiki_excerpt.exp')
print('----------------------SHAKESPEARE.EXP-----------------------------------')
openFile('polish_wiki_excerpt.in')
print('------------------------SIMPLE.IN------------------------------------')
openFile('simple.in')
print('-----------------------SIMPLE.EXP--------------------------------------')
openFile('simple.exp')