変数Intadd
を数値0から変更しようとしていますが、Intadd
が関数に含まれているため0になりません何。変数Intadd
を関数外に移動しようとしましたが、割り当て前にIntadd
がすでにrefferencedされています(私のコード全体でIntadd
が実行されています)。関数内の値を変更する変数を取得する方法
dictfile = open('c:/ScienceFairDictionaryFolder/wordsEn.txt', 'r')
DictionaryWords = dictfile.readlines()
def Number_Finder():
for x in DictionaryWords:
Intadd = 0
print(Intadd)
if x.replace("\n", str(Intadd)) == Password:
print("Congrats, you found the password!")
break
else:
while Intadd < 10:
Intadd += 1
お世話になりました!
は、 'グローバル' のキーワードで操作しよう: http://stackoverflow.com/questions/423379/using-global-variables-in- a-function-the-one-that-created-themそれら以外の機能 – fafnir1990