-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
21 lines (17 loc) · 1.07 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
morse_symbols = {
"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": "––··", "1": "·––––", "2": "··–––", "3": "···––", "4": "····–", "5": "·····", "6": "–····", "7": "––···",
"8": "–––··", "9": "––––·", "0": "–––––", ".": ".-.-.-", ",": "--..--", ":": "---...", "?": "..--..", "'":".----.",
"-": "-....-", "/": "-..-.", "(": "-.--.-", ")": "-.--.-", '"': ".-..-.",
}
text = input("Enter a word: ").upper()
morse_code = ""
for letter in text:
for symbol in morse_symbols:
if letter == " ":
morse_code += " "
elif letter == symbol:
morse_code += f"{morse_symbols.get(symbol)}/"
print(morse_code)