我對Python很陌生,所以如果這是一個愚蠢的錯誤,請原諒我!Python錯誤TypeError:字符串索引必須是整數
我一直在密碼生成器工作,目前在科技俱樂部。它的工作原理是它要求你輸入一個單詞。你輸入的單詞變成了一個列表。然後它將列表中的每個字母更改爲其他內容以創建唯一密碼(這是有缺陷的,我知道)。當我運行代碼時,它說TypeError: string indices must be integers
。我的代碼有什麼問題?
print ("Leo's Password Generator")
print ('Please enter a word')
word = input()
print ('Enter another word:')
word2 = input()
word = word2 + word
word.split()
def print_list(toon):
for i in toon:
if toon[i] == 'e':
toon[i] = '0'
print_list(word)
print (word)
根據你對furkle的回答的評論,我已經編輯了你的文章一點點,以澄清你的預期行爲。如果我歪曲了你,請告訴我! – 2014-11-03 23:58:49