jfz-2023-s473564/TaskA02/run.py
2023-10-26 20:29:58 +02:00

41 lines
1.1 KiB
Python

path = "TaskA02\polish_wiki_excerpt.in"
file = open(path,"r",encoding="utf8")
count = 0
lines_count = 0
used = False
lines = []
all_lines = file.readlines()
i = 0
for l in all_lines:
length = len(l.strip())
lines_count += 1
used = False
i = 0
for char in l:
i += 1
if i != 1:
if char == " " and count == 0:
count += 1
if (char == "p" or char == "P") and (count == 0 or count == 1):
count += 1
elif (char == "i" or char == "I") and (count == 1 or count == 2):
count += 1
elif (char == "e" or char == "E") and (count == 2 or count == 3):
count += 1
elif (char == "s" or char == "S") and (count == 3 or count == 4):
count += 1
if length == i:
count = 0
if used == False:
lines.append(lines_count)
used = True
elif (char == " ") and (count == 4 or count == 5):
count = 0
if used == False:
lines.append(lines_count)
used = True
else:
count = 0
print(lines)
file.close()