没有得到正确的结果,需要解密代码的帮助
# need help with code
cipher = ''
decipher = ''
choice = ''
while choice != 0:
choice = input('Press 1 to encrypt your text \nPress 2 to decrypt your
cipher text \n:')
if choice == '1':
cipher = input('Enter text to encrypt').lower()
for letter in cipher:
if(letter != ''):
cipher += the_bacon[letter]
print(cipher)
break>>> Press 1 to encrypt your text
>>> Press 2 to decrypt your cipher text
:1
>>> Enter text to encrypt
hello world
hello worldaabbb
hello worldaabbbaabaa
hello worldaabbbaabaaababb
hello worldaabbbaabaaababbababb
hello worldaabbbaabaaababbababbabbba需要创建替代培根密码和它不能正常工作,也需要帮助与解密代码
发布于 2019-05-01 01:39:37
假设您的the_bacon是一个具有1对1字母交换的适当字典,那么您的问题在于您是附加在输入上,而不是创建一个新的输出对象,然后将其打印出来。
您还可以使用while not choice:来表示循环,直到它们响应为止。除非你打算先把它转换成int类型,否则!= 0永远不会发生。
cipher = ''
decipher = ''
choice = ''
while not choice:
choice = input('Press 1 to encrypt your text \nPress 2 to decrypt your
cipher text \n:')
if choice == '1':
in_cipher = input('Enter text to encrypt').lower()
out_cipher = ''
for letter in in_cipher:
if(letter != ' '):
out_cipher += the_bacon[letter]
print(out_cipher) # print output letter by letter as it builds
print(out_cipher) # print the output
else:
# you need to decipher here and handle choices not 1 or 2https://stackoverflow.com/questions/55925461
复制相似问题