-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorse_encode.py
More file actions
executable file
·17 lines (16 loc) · 1.16 KB
/
morse_encode.py
File metadata and controls
executable file
·17 lines (16 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! /usr/bin/python
DICT = {'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': '--..',\
'0': '-----','1': '.----','2': '..---','3': '...--','4': '....-','5': '.....','6': '-....','7': '--...','8': '---..','9': '----.', \
'\r': '...-.-', '\n': '-.-.-', '@': '.--.-.', '~': '------.', '{': '----.--', '[': '-.--.--', ']': '-.---.-', '\\': '-.---..', '_': '..--.-', '^': '-.----.', '>': '-----.',\
'!': '-.-.--', '`': '--.....', '?': '..--..','#': '-...--', '"': '.-..-.', '%': '-..-.-', '$': '...-..-', "'": '.----.', '&': '.-...', ')': '-.--.-', '(': '-.--.', '+': '-.-.--', \
'*': '-.-.-.', '-': '-.--.-', '}': '-----.-', '<': '----..', ';': '-.-.-.', ':': '---...', '=': '-...-', '|': '-----..', '.': '.-.-.-',',': '--..--', '/': '-..-.', }
def main():
msg = raw_input('INPUT: ')
for char in msg:
if char == ' ':
print ' ',
else:
print DICT[char.upper()],
if __name__ == "__main__":
main()