Adding doctests to frequency_finder.py (#10341)

* Update frequency_finder.py

* Update frequency_finder.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Iyiola Aloko 2023-10-24 17:53:31 -04:00 committed by GitHub
parent dab4e64896
commit 76acc6de60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,6 +49,15 @@ def get_item_at_index_zero(x: tuple) -> str:
def get_frequency_order(message: str) -> str: def get_frequency_order(message: str) -> str:
"""
Get the frequency order of the letters in the given string
>>> get_frequency_order('Hello World')
'LOWDRHEZQXJKVBPYGFMUCSNIAT'
>>> get_frequency_order('Hello@')
'LHOEZQXJKVBPYGFWMUCDRSNIAT'
>>> get_frequency_order('h')
'HZQXJKVBPYGFWMUCLDRSNIOATE'
"""
letter_to_freq = get_letter_count(message) letter_to_freq = get_letter_count(message)
freq_to_letter: dict[int, list[str]] = { freq_to_letter: dict[int, list[str]] = {
freq: [] for letter, freq in letter_to_freq.items() freq: [] for letter, freq in letter_to_freq.items()