forked from zahariev-webbersof/python-mini-projects
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorse_code_script.py
More file actions
Latest commit
15 lines (11 loc) · 573 Bytes
/
Copy pathmorse_code_script.py
File metadata and controls
15 lines (11 loc) · 573 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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": "--..",
}
# Taking input from a user
data=input("Enter text: ")
length=len(data)
# Convert to Morse code in list comprehension
output= [symbols.get(data[i]) foriinrange(length) ifdata[i] insymbols.keys()]
print(' '.join(output))