我正在尝试制作一个密码破解游戏,其中用户将符号/字母对提交给字典以破解代码,然后我希望代码使用字典用配对字母替换符号的每个实例。
我有以下代码:
words = imported list of coded words where each letter is replaced by a symbol. from a text file so i can change later
clues = dictionary of symbol and letter pairs that can be added to, removed from
我尝试了以下方法,但失败了:TypeError: list indices must be integers, not str
def converter(words,clues):
progression = words
for words in progression:#cycles through each coded word in the list
for key in clues: #for each symbol in the dictionary
progression[words] = progression[words].replace(key, clues[key]) #replaces
return progression
任何人都可以提供的任何帮助,我将不胜感激。
亚当