基本上我一直在尝试制作一个凯撒密码类型的程序,
caesar=[
"x",
"y",
"z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w"
]
tempword=input('What would you like to encrypt? ')
list(tempword)
checklet=0
caesarlet=caesar[checklet]
for x in range(len(tempword)):
caeserlet=caesar[checklet]
tempword[checklet]=caesarlet
checklet=checklet+1
str(tempword)
print('Done encrypting, your word is: ',tempword)
但这一行似乎总是有一个错误:
tempword[checklet]=caesarlet
下面是输出的错误:
Traceback (most recent call last):
File "c:\Users\waisinz\Documents\python stuff\caesarcipher.py", line 35, in <module>
tempword[checklet]=caesarlet
TypeError: 'str' object does not support item assignment
我已经在网站上找到了一些解决方法,但我那弱小的大脑太光滑了,无法理解其中的任何一个。有谁知道一个简单的解决方法吗?