← Back to challenges

Morse Alphabet

PythonHarddata_structurescryptography

Instructions

Given is a dict with the Morse alphabet, added a code for space between words. Write a function, which takes a string, either out of letters or out of Morse code from the dictionary. The function outputs an encrypted letter string of a decrypted Mmorse code.

Examples

morse("F Mueller") ➞ "..-. ..... -- ..- . .-.. .-.. . .-."

morse(".--- --- .... -. ..... ..-. ..... -.- . -. -. . -.. -.--") ➞ "JOHN F KENNEDY"

morse("Barack Obama") ➞ "-... .- .-. .- -.-. -.- ..... --- -... .- -- .-"

Notes

  • You can use capital or small letters, however Morse always returns capitals.
  • Use only letters and Morse codes from the dictionary.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.