Create a function that takes a string (morse code) as an argument and returns an unencrypted string.
decode_morse(".... . .-.. .--. -- . -.-.--") ➞ "HELP ME !"
decode_morse("-.-. .... .- .-.. .-.. . -. --. .") ➞ "CHALLENGE"
decode_morse(". -.. .- -... -... .. - -.-. .... .- .-.. .-.. . -. --. .") ➞ "EDABBIT CHALLENGE"
The following dict can be used for coding:
morse_to_dots = {
"A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.",
"G": "--.", "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..",
"M": "--", "N": "-.", "O": "---", "P": ".--.", "Q": "--.-", "R": ".-.",
"S": "...", "T": "-", "U": "..-", "V": "...-", "W": ".--", "X": "-..-",
"Y": "-.--", "Z": "--..", "0": "-----",
"1": ".----", "2": "..---", "3": "...--", "4": "....-", "5": ".....",
"6": "-....", "7": "--...", "8": "---..", "9": "----.",
"&": ".-...", "'": ".----.", "@": ".--.-.", ")": "-.--.-", "(": "-.--.",
":": "---...", ",": "--..--", "=": "-...-", "!": "-.-.--", ".": ".-.-.-",
"-": "-....-", "+": ".-.-.", '"': ".-..-.", "?": "..--..", "/": "-..-."
}
dots_to_morse = {}
for key, val in morse_to_dots.items():
dots_to_morse[val] = key