I am trying to translate Morse code into English with a dictionary I used. I am trying to have it where a user inputs a message and it will print his/her message into Morse code.
I found it easy to translate into Morse code, however Morse code to English gives me some issues.
First, if I type '.-' for 'A' I actually get 'E' instead as it's reading the first '.' key and translating it into 'E' instead of taking the whole string.
This is what I have tried so far :)
#If user types 'N' or 'n' it proceeds this loop
if morse_message == 'N' or morse_message == 'n': #Loops looks to see if morse_message was 'N' or 'n'
nomorse = input("Enter your Morse code here:")
nomorse_list = (nomorse.join('')
for letter in nomorse_list:
not_morse = (morse_eng_dict[letter.upper()])
print(not_morse)
And this is my dictionary I have
morse_eng_dict = {".-": "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"}
I would like to have Python take my Morse code and print the message back into English. Such as something like .. . .-.. .-.. --- (Which is HELLO)
This is for a project, so I can't use any fancy modules or anything. Any ideas or input? Thank you!