Morse Message Decoder
Morse code represents text using short and long signals, so decoding it is a nice way to practice splitting strings and using a dictionary. Write decode_morse, which takes a dictionary morse and a string message, then converts the codes back into regular characters. Letters are separated by one space, words are separated by three spaces, and any extra spaces around the message should be ignored.
Примеры
Ввод
{".-": "A", "-...": "B", "-.-.": "C"}, ".-"Вывод
"A"Ввод
{".....": "5", "....-": "4", "...--": "3"}, "..... ....-"Вывод
"54"Ввод
{".-": "A", "-...": "B", "-.-.": "C"}, " .- -... -.-. "Вывод
"AB C"Нужно реализовать
def decode_morse(morse: dict, message: str) -> str:
Теги
stringsdict
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänTests12
Visible tests
Piilotettu testi 7
Piilotettu testi 8
Piilotettu testi 9
Piilotettu testi 10
Piilotettu testi 11
Piilotettu testi 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid