0
我有这个代码,它是一个基本的凯撒密码,偏移量设置为1,但我希望它可以让用户输入偏移量。用户应该能够通过字母多少在由感动地说,但它不会工作,如果偏移=输入如何在Python中输入凯撒密码的偏移量
#Caesar cipher
sentance = input('Enter sentance: ')
alphabet = ('abcdefghijklmnopqrstuvwxyz')
offset = 1
cipher = ''
for c in sentance:
if c in alphabet:
cipher += alphabet[(alphabet.index(c)+offset)%(len(alphabet))]
print('Your encrypted message is: ' + cipher)