Untitled
unknown
plain_text
4 years ago
689 B
4
Indexable
import string # Main # Nhập input num_of_line = int(input()) text = "" for i in range(num_of_line): text += " " + input() # list các dấu punctuation = list(string.punctuation) # thay các dấu bằng khoảng trắng for i in punctuation: if i in text: text = text.replace(i, " ") # chia từ words = text.lower().split() # thống kê word_occerence = {} for word in words: if word in word_occerence: word_occerence[word] += 1 else: word_occerence[word] = 1 word_occerence = dict(sorted(word_occerence.items(), key=lambda x: (-x[1], x[0]))) for key, value in word_occerence.items(): print(f"{key} {value}")
Editor is loading...