无法获得正确的结果,需要解密代码方面的帮助
count([], 0).
count([H|T], N) :-
count(T, X),
( H = 0
-> N is X+1
; N is X
).
# 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
需要创建替换培根密码并且它不能正常工作,也需要帮助来解密代码
答案 0 :(得分:0)
假设您的the_bacon
是正确的字典,具有1到1个字母交换,那么您的问题是您要在输入上追加而不是创建新的输出对象然后进行打印。
您也可以使用while not choice:
来表示要循环播放,直到他们回答为止。除非您首先要将其变成!= 0
类型,否则int
永远不会发生。
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 2