-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathistiklal.py
More file actions
30 lines (29 loc) · 948 Bytes
/
istiklal.py
File metadata and controls
30 lines (29 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import re
'''
Soru: On kıtadan oluşan İstiklal Marşı'nın tamamında bu kelimelerden hangisi daha az geçer?
A) Vatan B) Kan C) Toprak D) Yurt
'''
with open('istiklal.txt', encoding='utf-8') as x:
firstList = []
# x=x.readlines()
for i in x.readlines():
firstList.append(i.strip().split())
dictList = {}
dictList2 = {'toprak': 0, 'vatan': 0, 'yurt': 0, 'kan': 0}
for i in range(len(firstList)):
for j in firstList[i]:
j = re.sub(r'\W+', '', j).lower()
if 'toprak' in j or 'toprağ' in j:
dictList2['toprak'] += 1
elif 'vatan' in j:
dictList2['vatan'] += 1
elif 'yurt' in j or 'yurd' in j:
dictList2['yurt'] += 1
elif 'kan' in j:
dictList2['kan'] += 1
#if not j in dictList:
# dictList[j] = 1
#else:
# dictList[j] += 1
# print(dictList)
print(dictList2)