0
私はPythonでCaesar Ciphers関数を作成しようとしていますが、小文字だけで動作するように見えますが、大文字を扱う方法は?私はPythonでCaesar Ciphers関数を作成しようとしていますが、小文字だけで動作するようですが、大文字で作業する方法は?
a = dict(zip("abcdefghijklmnopqrstuvwxyz",range(26)))
b = dict(zip(range(26),"abcdefghijklmnopqrstuvwxyz"))
key = int(input('Enter the key:'))
plaintext = (input('Enter your message:'))
ciphertext = ""
for c in plaintext:
if c.isalpha():
ciphertext += b[ (a[c] + key)%26 ]
else: ciphertext += c
plaintext2 = ""
for c in ciphertext:
if c.isalpha():
plaintext2 += b[ (a[c] - key)%26 ]
else: plaintext2 += c
print(plaintext,",",ciphertext,",",plaintext2)
大文字はどうしますか?それは2つのドメインでなければならないので、大文字は大文字に、小文字は小文字に置き換えられますか?または、大文字小文字に変換するだけですか?あなたの質問は十分に指定されていません。 – JohanL