Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MORSE_CODE_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': '--..',
- '1': '.----', '2': '..---', '3': '...--',
- '4': '....-', '5': '.....', '6': '-....',
- '7': '--...', '8': '---..', '9': '----.',
- '0': '-----', ', ': '--..--', '.': '.-.-.-',
- '?': '..--..', '/': '-..-.', '-': '-....-',
- '(': '-.--.', ')': '-.--.-'}
- qd_file = open("morse.txt", "a")
- def encrypt(message):
- cipher = ''
- for letter in message:
- if letter != ' ':
- cipher += MORSE_CODE_DICT[letter] + ' '
- else:
- cipher += ' '
- return cipher
- input_ = input("Input: ").upper()
- output = encrypt(input_)
- print(encrypt(input_))
- qd_file.write(" ( " + input_ + " = " + output + " ) ")
- qd_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement