How to Decoding Morse and Encoding Morse with Python
Python Morse Converter
Maybe one day you can meet an asume alien girl however she don’t know any language except morse alphabet (she communicates only this way:-)). So, what will you do? Dont be sad cause i wrote a python code to decode what she says and encode yours.
1 - MORSE=[".-","-...","-.-.","-..",".","..-.",
2 - "--.","....","..",".---","-.-",
3 - ".-..","--","-.","---",".--.",
4 - "--.-",".-.","...","-","..-",
5 - "...-",".--","-..-","-.--","--.."]
6 - SP=["a","b","c","d","e",
7 - "f","g","h","i","j",
8 - "k","l","m","n","o",
9 - "p","q","r","s","t",
10 - "u","v","w","x","y","z"]
11 - def encode(normal):
12 - encoding=""
13 - for i in range(len(normal)):
14 - encoding+=MORSE[SP.index(normal[i])]
15 - encoding+=" "
16 - print encoding
17 - def decode(morse):
18 - normal=""
19 - morse=morse.split(" ")
20 - for i in range(len(morse)):
21 - normal+=SP[MORSE.index(morse[i])]
22 - print normal
23 -
24 - choice=int(raw_input("Choose the operation\n1-Normal To Morse\n2-Morse To Normal\nChoice:"))
25 - if(choice==1):
26 - expression=raw_input("Type your words without spaces:")
27 - encode(expression)
28 - elif(choice==2):
29 - expression=raw_input("Type your morse expresion:")
30 - decode(expression)
31 -
This Code is About: How to Decoding Morse and Encoding Morse with Python, Decode Morse,Encode to Morse,Morse Encoding,raw_input,Python