41 lines
1006 B
Python
41 lines
1006 B
Python
|
def is_number(char):
|
||
|
numbers = ['0','1','2','3','4','5','6','7','8','9']
|
||
|
for i in numbers:
|
||
|
if char == i:
|
||
|
return True
|
||
|
|
||
|
path = "TaskA03\polish_wiki_excerpt.in"
|
||
|
file = open(path,"r",encoding="utf8")
|
||
|
count = 0
|
||
|
lines_count = 0
|
||
|
used = False
|
||
|
lines = []
|
||
|
all_lines = file.readlines()
|
||
|
for l in all_lines:
|
||
|
lines_count += 1
|
||
|
used = False
|
||
|
for char in l:
|
||
|
if char == "1":
|
||
|
count += 1
|
||
|
elif char == "9" and count == 1:
|
||
|
count += 1
|
||
|
elif count == 2 and is_number(char) == True:
|
||
|
count += 1
|
||
|
elif count == 3 and is_number(char) == True:
|
||
|
count += 1
|
||
|
elif char == " " and count == 4:
|
||
|
count += 1
|
||
|
elif char == "r" and count == 5:
|
||
|
count += 1
|
||
|
elif char == "." and count == 6:
|
||
|
count = 0
|
||
|
if used == False:
|
||
|
lines.append(lines_count)
|
||
|
used = True
|
||
|
else:
|
||
|
count = 0
|
||
|
|
||
|
print(lines)
|
||
|
file.close()
|
||
|
|
||
|
|