Edited TaskAO1

This commit is contained in:
IgnBys 2023-10-27 16:57:36 +02:00
parent 4aa4b6f6ec
commit c72706db07
3 changed files with 47 additions and 1 deletions

46
TaskA01/TaskAO1.py Normal file
View File

@ -0,0 +1,46 @@
import re
def openFile(fileName,hamletArray = ['H','a', 'm', 'l', 'e', 't'], hamletFullWord = r'Hamlet'):
with open(fileName, "r", encoding="utf-8") as file:
file_contents = file.read()
repCounter = 0
line = ''
counter = 0
checkWord = ''
index = 0
length = len(file_contents)
while index < length:
character = file_contents[index]
line += character
if len(checkWord) < len(hamletFullWord):
if character == hamletArray[counter]:
checkWord+=character
counter += 1
else:
checkWord = ''
counter = 0
if character=='\n':
if checkWord=='Hamlet':
print(line)
line = ''
counter = 0
checkWord = ''
index+=1
#
print('---------------------SHAKESPEARE.EXP--------------------------------------')
openFile('shakespeare.exp')
print('----------------------SHAKESPEARE.EXP-----------------------------------')
openFile('shakespeare.in')
print('------------------------SIMPLE.IN------------------------------------')
openFile('simple.in')
print('-----------------------SIMPLE.EXP--------------------------------------')
openFile('simple.exp')

0
TaskA04/TaskAO4.py Normal file
View File

View File

@ -1,4 +1,4 @@
34234 34 dfd gfd 5
cd jfz34234 34 dfd gfd 5
34535
fsdflskfjsdflk
fsdkfj sdf34fdfd