Edited TaskAO2

This commit is contained in:
IgnBys 2023-10-20 17:30:16 +02:00
parent 3612707923
commit 4581b8be4d

View File

@ -1,9 +1,4 @@
# piesArray = [r'[Pp ]', 'i', 'e', 's', r'[ \t\n.,;!?]']
# pies = ['p', 'i', 'e', 's', '.']
# if pies == piesArray:
# print('true')
def openFile(fileName,piesArray = ['[Pp ]', 'i', 'e', 's', '[ \t\n.,;!?]'], patterns = [r'[Pp ]', 'i', 'e', 's', r'[ \t\n.,;!?]']):
def openFile(fileName,piesArray = ['[Pp ]', 'i', 'e', 's', '[ \t\n.,;!?]']):
with open(fileName, "r", encoding="utf-8") as file:
for row in file:
repCounter = 0
@ -12,9 +7,7 @@ def openFile(fileName,piesArray = ['[Pp ]', 'i', 'e', 's', '[ \t\n.,;!?]'], patt
for i in row:
if i in piesArray[counter]:
if i != ' ' or counter != 0:
# print(piesArray[4])
checkWord+=i
# print(checkWord)
counter+=1
if len(checkWord) >= 5:
sum = 0
@ -29,11 +22,6 @@ def openFile(fileName,piesArray = ['[Pp ]', 'i', 'e', 's', '[ \t\n.,;!?]'], patt
if repCounter == 1:
print(row.strip())
# 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