mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
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:
parent
dab4e64896
commit
76acc6de60
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user