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)