plaintext =[
"this is a test",
"caesar’s wife must be above suspicion",
"as shatner would say: you, should, also, be, able, to, handle, punctuation.",
"to mimic chris walken: 3, 2, 1, why must you, pause, in strange places?",]
shift = 3
def caesar(plaintext):
alphabet=["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"]
dic={}
for i in range(0,len
(alphabet)):
dic[alphabet[i]]=alphabet[(i+shift)%len(alphabet)]
ciphertext=""
for l in plaintext():
if l in dic:
l=dic[l]
ciphertext+=l
return ciphertext
print [caesar(plaintext)]
なぜ私にエラーが出るのか分かりません。私は援助が必要です。私は括弧を入れて、パラセシスを置き換えようとしましたが、それでもそのエラーが出ています。エラーが発生しましたこのシーザー暗号でリストオブジェクトを呼び出すことができません
Traceback (most recent call last):
File "C:/Users/iii/Desktop/y.py", line 33, in <module>
print (caesar(plaintext))
File "C:/Users/iii/Desktop/y.py", line 24, in caesar
for l in plaintext():
TypeError: 'list' object is not callable
まず最初に、 'print(caesar(plaintext))'はPython 3.xでの印刷方法です。 – ifconfig
それでも同じエラーを出すことは変わりません –
あなたの質問に完全なエラートレースバックを追加してください。 plaintext()のlの –