My Morse Code Encryption function doesn't work, how can I identify anything that could be causing this?
(我的摩尔斯电码加密功能不起作用,如何识别可能导致这种情况的任何东西?)
When implemented into my main program, it will work up to the input field for users to enter a message to be encrypted, but then it fails once I press enter. (当在我的主程序中实现后,它将在输入字段中起作用,以便用户输入要加密的消息,但是一旦按Enter键,它就会失败。)
The error is that it tells me that Run Encryption is invalid, but the choice Run Encryption is properly coded to access the encrypt() function.
(错误是,它告诉我“运行加密”无效,但是对“运行加密”选项进行了正确的编码以访问crypto()函数。)
C:UsersmatloPycharmProjectsPythonLearningvenvScriptspython.exe C:/Users/matlo/PycharmProjects/PythonLearning/ProgramwBasics.py
Hello, World!
----------------------------------------
What is your name?:Matt
Hello! Matt
----------------------------------------
What do you want to do?:Run Encryption
Message to be Encrypted: HELLO
'Run Encryption'is invalid.
Maybe try:
Open Chrome
Date and Time
Calculator
Times Table
Run Encryption
Terminate
What do you want to do?:
Code:
(码:)
CODE = {' ': '_',
"'": '.----.',
'(': '-.--.-',
')': '-.--.-',
',': '--..--',
'-': '-....-',
'.': '.-.-.-',
'/': '-..-.',
'0': '-----',
'1': '.----',
'2': '..---',
'3': '...--',
'4': '....-',
'5': '.....',
'6': '-....',
'7': '--...',
'8': '---..',
'9': '----.',
':': '---...',
';': '-.-.-.',
'?': '..--..',
'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': '--..',
'_': '..--.-'}
def encrypt():
sentence = input("Message to be Encrypted: ")
encoded_sentence = ""
for character in sentence:
encoded_sentence += CODE[character] + " "
return encoded_sentence
ask by Matthew Lodge translate from so