- Write a function that takes as input (sentence: String, n: Number)
and returns a list of size
n
where each element contains a word and and the frequency of that word insentence
This list should be sorted by decreasing frequency and alphabetical order in case of tie.
Example: Input: ("bar baz foo foo zblah zblah zblah baz toto bar", 3) Output: [ ("zblah", 3), ("bar", 2), ("baz", 2), ]
- Write tests for the function you just wrote
To run the tests, you need to install pytest like so :
pip install pytest
and then run the tests using the command :
pytest