Home python Alphabappish Morse translation to Russian letters

Alphabappish Morse translation to Russian letters

Author

Date

Category

There is a code for the translation of the Morse code in the letters, but it does not want to translate more than two letters. How can I convert code, so that all letters separated by spaces were translated into the text?

message = input ("Please Type A Message to Encrypt:")
new_message = ""
Letters = {".-": "A",
      "-...": "b",
      "-.-.": "C",}
If Letters [Message]:
  New_Message = Letters [Message]
ELSE:
  New_Message = "This Cannot Be Turned to Morse Code"
Print (new_message)

Answer 1, Authority 100%

message = input ("Please Type A Message to Encrypt:")
Letters = {"A": ".-",
      "B": "-...",
      "C": "-.-.",
      ...
}
new_message = ""
For CH in Message:
  Try:
    New_Message + = Letters.get (CH)
  Except:
    Print ('This Symbol Cannot Be Turned to Morse Code')
    EXIT (0)
Print (new_message)

Answer 2

something like this:

message = input ("Please Type A Message to Encrypt:")
new_message = ""
Letters = {".-": "A",
      "-...": "b",
      "-.-.": "C",}
For Char in Message.Split ():
  if char in letters:
    New_Message + = Letters [Char]
  ELSE:
    New_Message = "This Cannot Be Turned to Morse Code"
    Break
print (new_message)

Only the English inscription while you say that you are on the contrary translate text into Morse code.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions