-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.8.py
31 lines (27 loc) · 974 Bytes
/
1.8.py
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
31
import os
from collections import Counter
def report(file_name, type):
with open(file_name, "r", encoding=type) as file:
results = []
for line in file:
for word in line.split(" "):
if len(word) >= 6:
results.append(word)
answer = Counter(results).most_common(10)
for i in answer:
print("Слово:", i[0], "\nКоличество упоминаний в тексте: ", i[1])
def main():
while True:
console = input("Choose a file to open:\n1-France\n2-Africa\n3-Cyprus\n4-Italy\nQ-for quit")
if console == "1":
report("newsfr.txt", None)
elif console == "2":
report("newsafr.txt", "utf-8")
elif console == "3":
report("newscy.txt", None)
elif console == "4":
report("newsit.txt", None)
elif console.lower() == "q":
break
os.system("pause")
main()