Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print('Здравствуйте, вас приветствует программа Код Морзе')
- name = input('Как вас зовут?\n')
- letters = 'А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я'
- letters = letters. split()
- morse = '.- -... .-- --. -.. . ...- --.. .. .--- -.- .-.. -- -. --- .--. .-. ... - ..- ..-. .... -.-. ---. ---- --.- --.-- -.-- -..- ..-.. ..-- .-.-'
- morse = morse.split()
- while True:
- answer = input(f'{name}, если вы хотите зашифровать, то нажмитье букву З, а если расшифровать - букву Р').lower()
- while answer not in ['р', 'з']:
- answer = input(f'{name}, если вы хотите зашифровать, то нажмитье букву З, а если расшифровать - букву Р').lower()
- text = ''
- translated_message = []
- message = input(f'{name}, введи свое сообщение\n').upper()
- if answer == 'з':
- list_incode = dict(zip(letters, morse))
- for complex in message:
- if complex not in list_incode:
- translated_message.append(complex)
- else:
- translated_message.append(list_incode[complex])
- text = ''.join(translated_message)
- elif answer == 'р':
- list_decode = dict(zip(morse, letters))
- message = message.split()
- for complex in message:
- if complex not in list_decode:
- translated_message.append(complex)
- else:
- translated_message.append(list_decode[complex])
- text = ''.join(translated_message)
- print(text)
- answer1 = input(f'Хотите воспользоваться программой еще раз? Да или Нет\n').lower()
- if answer1 == "да":
- print('Сделайте свой выбор снова')
- else:
- print('До свидания!')
- break
Advertisement
Add Comment
Please, Sign In to add comment