Skip to content

Commit 3ccad52

Browse files
committed
feat: Added text to morse code program.
1 parent 9dfa3d0 commit 3ccad52

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Text to Morse Code/main.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
symbols = {
2+
"a": ".-",
3+
"b": "-...",
4+
"c": "-.-.",
5+
"d": "-..",
6+
"e": ".",
7+
"f": "..-.",
8+
"g": ".-",
9+
"h": "....",
10+
"i": "..",
11+
"j": ".---",
12+
"k": "-.-",
13+
"l": ".-..",
14+
"m": "--",
15+
"n": "-.",
16+
"o": "---",
17+
"p": ".--.",
18+
"q": "--.-",
19+
"r": ".-.",
20+
"s": "...",
21+
"t": "-",
22+
"u": "..-",
23+
"v": "...-",
24+
"w": ".--",
25+
"x": "-..-",
26+
"y": "-.--",
27+
"z": "--..",
28+
}
29+
30+
ask = input("Enter a word: ")
31+
length = len(ask)
32+
output = ""
33+
34+
for i in range(length):
35+
if ask[i] in symbols.keys():
36+
output = output + " " + symbols.get(ask[i])
37+
38+
print(output)

0 commit comments

Comments
 (0)