このコードを実行して、リストのすべての要素に対して関数を実行しようとしています。ここでの説明のために、基本的には次のように出力する必要があります。
'----------Possible Word:', possible_word
私のリストのすべてのアイテム。したがって、['p'、'r'、's']を入力すると、それらの項目ごとに1つずつ、合計3回印刷が実行されます。私のコードは以下のとおりです-実行すると、rではなくpとsに対してのみ実行されますが、これは本当に奇妙なことです。何か案は?
def check_matches(input):
print 'Input:', input
for possible_word in input:
print '----------Possible Word:', possible_word
valid = True
for real_word in word_dictionary:
possible_word_list = list(possible_word)
real_word_list = list(real_word)
print possible_word_list
print real_word_list
number_of_characters_to_check = len(possible_word_list)
for x in range(0, number_of_characters_to_check):
print possible_word_list[x] + real_word_list[x]
if (possible_word_list[x] != real_word_list[x]):
valid = False
if (valid == False):
input.remove(possible_word)
print all_possible
return input