大家好,我有一个问题。为什么以下代码不产生任何输出或错误?
这是对用户代码进行加密和解密的代码
alpha = ['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']
shift = range(26)
def user_info():
info = input("\nPress 'e' to encrypt or 'd' to decrypt: ").lower()
if info == 'e' or 'd':
return info
def user_message():
code = input("What is your message?: ")
return code
def user_shift():
shift = int(input("What is your shift number?: "))
while True:
if shift == int(shift):
return shift
def True_Message(info, code, shift):
if info[0] == 'd': #This encrypts the code
shift = -shift
for letter in code:
if letter in alpha:
alpha_2 = ord(letter) + shift
secret_message = ""
if alpha_2 in range (0, len(alpha)):
final_mix = chr(alpha)
secret_message += final_mix
return secret_message
info = user_info()
code = user_message()
shift = user_shift()
print(True_Message(info, code, shift))
没有任何错误,所以我不知道出了什么问题。我是这个加密的新手,我不确定这是否在正确的轨道上,有什么想法吗?谢谢你。
更新!!!!!
抱歉,我希望代码能够根据用户的选择加密和解密代码