# Write a program to compute the frequency of the words from the input

• Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically.
• Suppose the following input is supplied to the program:
• New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.
• Then, the output should be:
• 2:2
• 3.:1
• 3?:1
• New:1
• Python:5
• and:1
• between:1
• choosing:1
• or:2
• to:1

#### Hints:

• In case of input data being supplied to the question, it should be assumed to be a console input.

## Solution:

```.wp-block-code {
border: 0;
}

.wp-block-code > span {
display: block;
overflow: auto;
}

.shcb-language {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
position: absolute;
width: 1px;
word-wrap: normal;
word-break: normal;
}

.hljs {
box-sizing: border-box;
}

.hljs.shcb-code-table {
display: table;
width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
color: inherit;
display: table-row;
width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
border-spacing: 0;
counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
}

.hljs.shcb-line-numbers .shcb-loc::before {
border-right: 1px solid #ddd;
content: counter(line);
display: table-cell;
text-align: right;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: 1%;
}
```freq = {}   # frequency of words in text
line = raw_input()
for word in line.split():
freq[word] = freq.get(word,0)+1

words = freq.keys()
words.sort()

for w in words:
print "%s:%d" % (w,freq[w])
```Code language: Python (python)```