Task1 was ended

This commit is contained in:
IgnBys 2023-10-18 22:37:24 +02:00
parent 0c23da0e15
commit 92361f3372

28
TaskA01/Task1.py Normal file
View File

@ -0,0 +1,28 @@
def openFile(fileName,hamletArray = ['H','a', 'm', 'l', 'e', 't']):
with open(fileName, "r", encoding="utf-8") as file:
for row in file:
repCounter = 0
counter = 0
checkWord =''
for i in row:
if i == hamletArray[counter]:
checkWord+=i
counter+=1
if checkWord == 'Hamlet':
checkWord = ''
counter = 0
repCounter+=1 #if in one row more than one Hamlet it will write the row only once
if repCounter == 1:
print(row.strip())
else:
checkWord = ''
counter = 0
print('---------------------SHAKESPEARE.EXP--------------------------------------')
openFile('shakespeare.exp')
print('----------------------SHAKESPEARE.EXP-----------------------------------')
openFile('shakespeare.in')
print('------------------------SIMPLE.IN------------------------------------')
openFile('simple.in')
print('-----------------------SIMPLE.EXP--------------------------------------')
openFile('simple.exp')