-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextfile.txt
More file actions
12 lines (10 loc) · 879 Bytes
/
textfile.txt
File metadata and controls
12 lines (10 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
PYTHON
python
tores tuples that contain the frequency of a word, the word itself and the line
#in which the number appears.
Hello
My Name is Jose francisco
Write a program that counts the frequencies of each word in a text, and output each word with its count and line numbers where it appears.
We define a word as a contiguous sequence of non-white-space characters. Different capitaliz atio ns o f the same character sequence should be considered same word (e.g. Python and python).
The output is formatted as follows: each line begins with a number indicating the frequency of the word, a white space, then the word itself, and a list of line numbers containing this word.
You should output from the most frequent word to the least frequent. In case two words have the same frequency, the lexicographically smaller one comes first. All words are in lower case in the output.