This Python script converts a given paragraph of text into Morse code. It uses a predefined dictionary to map each character to its corresponding Morse code representation.
- Converts letters, digits, and a selection of special characters to Morse code.
- Handles both uppercase and lowercase input by converting all text to uppercase.
- Represents spaces in the original text with a slash (
/
) in Morse code.
- Clone or download this repository.
- Ensure you have Python installed on your system.
- Run the script and enter a paragraph of text when prompted.
Hello, World!
.... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--
The script uses the following Morse code mappings:
Character | Morse Code | Character | Morse Code |
---|---|---|---|
A | .- | N | -. |
B | -... | O | --- |
C | -.-. | P | .--. |
D | -.. | Q | --.- |
E | . | R | .-. |
F | ..-. | S | ... |
G | --. | T | - |
H | .... | U | ..- |
I | .. | V | ...- |
J | .--- | W | .-- |
K | -.- | X | -..- |
L | .-.. | Y | -.-- |
M | -- | Z | --.. |
0 | ----- | 5 | ..... |
1 | .---- | 6 | -.... |
2 | ..--- | 7 | --... |
3 | ...-- | 8 | ---.. |
4 | ....- | 9 | ----. |
, | --..-- | : | ---... |
. | .-.-.- | ; | -.-.-. |
? | ..--.. | = | -...- |
/ | -..-. | + | .-.-. |
- | -....- | _ | ..--.- |
( | -.--. | " | .-..-. |
) | -.--.- | $ | ...-..- |
& | .-... | ! | -.-.-- |
@ | .--.-. | Space | / |
- Clone the repository:
git clone https://github.com/your-username/morse-code-converter.git
- Navigate to the project directory:
cd morse-code-converter
- Ensure you have Python installed on your system.
- Run the script:
python morse_code_converter.py
- Enter a paragraph of text when prompted.
This project is licensed under the MIT License - see the LICENSE file for details.
- The Morse code dictionary was sourced from various online references.