#!/usr/bin/python3 # # This program reads a text file from the standard input, and prints # the most common word in the input. The words in the input are the # maximal-length sequences of alphabetic characters (e.g., a-z). So, # a word does not include spaces or punctuation characters. # import sys def line_to_words(line): words = [] w = '' for c in line: if c.isalpha(): w += c else: if not w == '': words.append(w) w = '' if not w == '': words.append(w) return words D = {} for l in sys.stdin: for w in line_to_words(l): if w in D: D[w] += 1 else: D[w] = 1 most_common = None max_freq = 0 for w in D: if D[w] > max_freq: most_common = w max_freq = D[w] print(most_common)