такой скрипт
MORSE = {
'а': '.-', 'б': '-...', 'в': '.--',
'г': '--.', 'д': '-..', 'е': '.',
'ж': '...-', 'з': '--..', 'и': '..',
'й': '.---', 'к': '-.-', 'л': '.-..',
'м': '--', 'н': '-.', 'о': '---',
'п': '.--.', 'р': '.-.', 'с': '...',
'т': '-', 'у': '..-', 'ф': '..-.',
'х': '....', 'ц': '-.-.', 'ч': '---.',
'ш': '----', 'щ': '--.-', 'ъ': '.--.-',
'ы': '-.--', 'ь': '-..-', 'э': '..-..',
'ю': '..--', 'я': '.-.-'
}
char, sym = None, None
seq = ''
STOP_SEQ = '000'
print('input \'{:s}\' at any time to confirm'.format(STOP_SEQ))
while char != STOP_SEQ:
char = input('input char:').lower()
try:
sym = MORSE[char]
seq += sym
print('{:s}'.format(sym))
except KeyError:
print('no such char found')
print('final string sequence is {:s}'.format(seq))
input '000' at any time to confirm
final string sequence is .....-...--.----.--
while symbol != 000:
if symbol=="а":
print(".--")
if symbol== "б":
print("--.")
if symbol == "000":
break