######################################################################## ######################################################################## # # Morse.py # write a function to return the Morse code for a text string # write a function to return the text string for a morse code string # ######################################################################## ######################################################################## # table that defines the ITU morse code standard for letters and numbers morse = { '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' : '--..', '1' : '.----', '2' : '..---', '3' : '...--', '4' : '....-', '5' : '.....', '6' : '-....', '7' : '--...', '8' : '---..', '9' : '----.', '0' : '-----' } # Note: need a single space between letters and a double space between words message = "hello world" def textToMorse(s): """Convert a text string s, containing letters numbers and spaces to Morse code""" code = "" # write your function here return code def morseToText(s): """Convert a text string s, containing '.','-' and ' ' to text""" text = "" # write your function here return text print('The message is in text "{}"'.format(message)) print('The message is in Morse code "{}"'.format(textToMorse(message))) print('The message is converted back to text "{}"'.format(morseToText(textToMorse(message))))