I'm trying to run this code so that it runs a function for all elements of a list. For illustrative purposes here, basically it should print:
'----------Possible Word:', possible_word
for all items in my list. So, if I were to input ['p', 'r', 's'] it would run that print 3 times, one for each of those items. My code is below - when I run it it only runs for p and s, not r, which is really odd. Any ideas?
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