私の単純なブルートフォースパスワードプログラムはこれまでどおり完璧に動作しますが、実行するたびに常に最後の最後を出力し、文字列インデックスが範囲外です。すべてうまく動作し、私が望む出力が得られますが、whileループが閉じてプログラムが実行を停止するたびにエラーが発生します。文字列インデックスが範囲外であるエラーPython forループ
userpassword = raw_input("Enter a password: ")
k = 0
cyclenumb = 0
newpasswordlist=[]
lowercaselist=["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"]
uppercaselist=["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"]
numberslist=["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
symbolslist=["~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "{", "[", "]", "}", "|", "\ ", ";", ":", "'", '"', ",", "<", ".", ">", "/", "?", " "]
while cyclenumb <= 10000:
for x in userpassword[k]:
for z in lowercaselist:
if x in z:
newpasswordlist.append(z)
k +=1
print newpasswordlist
if x is not z:
for x in userpassword[k]:
for z in uppercaselist:
if x in z:
newpasswordlist.append(z)
k +=1
print newpasswordlist
if x is not z:
for x in userpassword[k]:
for z in numberslist:
if x in z:
newpasswordlist.append(z)
k +=1
print newpasswordlist
if x is not z:
for x in userpassword[k]:
for z in symbolslist:
if x in z:
newpasswordlist.append(z)
k +=1
print newpasswordlist
if userpassword == newpasswordlist:
break
print newpasswordlist
print "Here is your original password " + userpassword
この簡単なエラーで私を助けてください。
「最後の最後」とは何ですか?エラーは何行目を参照していますか? –
行28、userpassword [k] – mansa
のxに対してですが、それはループのために開始する他の行、例えば35行目に変更されます。私は、userpasswordの最後の文字 – mansa