Morse Code (Python)

Python Morse Code Translator

11th January is #LearnYourNameInMorseCodeDay.

GCHQ Morse Code
GCHQ Morse Code

I found this out as GCHQ tweeted the following today:

GCHQ Morse Code Tweet

Which is Morse Code. I’ve never learned Morse Code, but wanted to know what GCHQ were tweeting about. I few solutions came to mind:

  1. Convert the morse manually
  2. Use an online tool to convert the Morse
  3. Build a Python tool to convert the Morse

As I have recently been getting to grips with ciphers in Python, and as I wanted a little challenge I went with option 3 and got Python to convert the Morse for me.

Python Morse Code Translator

I found it easier to translate English to Morse as I hit a small snag with looking up a dictionary key by its value. Thankfully StackOverFlow had the answer.

The complete Python code is available on my GitHub here:

.-.. . .- .-. -. / -.– — ..- .-. / -. .- — . / .. -. / — — .-. … . / -.-. — -.. .

If you like puzzles / challenges then I recommend following the GCHQ Twitter feed. There are also two GCHQ puzzle books, and they have a GitHub (

One thought on “Morse Code (Python)

Comments are closed.