Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit 4151e9e

Browse files
authored
Merge pull request #500 from RgTheGreat/text_to_morse_code
Create text_to_morse_code.py
2 parents c7dcc7f + 1dc810d commit 4151e9e

File tree

1 file changed

+42
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)