This is a simple Python script that allows users to encode a message into Morse code or decode a Morse code message back into English.
- Encode English text into Morse code
- Decode Morse code into English text
- Supports letters AβZ and numbers 0β9
- Uses
_
to represent space between words in encoding
- Run the Python script.
- Enter your message.
- Choose:
1
for encoding (text β Morse)2
for decoding (Morse β text)
Input: enter your message: hello world 1 - for ENCODING 2 - for DECODING enter your option: 1
Output: .... . .-.. .-.. --- _ .-- --- .-. .-.. -..
Input: enter your message: .... . .-.. .-.. --- _ .-- --- .-. .-.. -.. 1 - for ENCODING 2 - for DECODING enter your option: 2
Output: HELLOWORLD
- A dictionary
morse_code
maps letters and numbers to Morse symbols. - Another dictionary
alpha_code
is auto-generated to reverse this mapping for decoding. - Encoding processes each character of the input string.
- Decoding splits the Morse input by spaces and maps it back to text.
Just Python! No external libraries are required.
morse_code.py
β main script for encoding and decoding
This project is open-source and free to use under the MIT License.