def find_cell_en(self, query_word):
result_list = dict()
result_list.clear()
for row in self.reader:
en_name = row[0]
word_type = row[1]
key_entry = en_name + '#' + word_type
je_name = row[2]
# If the searched query is in the English key
if query_word.lower() in key_entry.lower():
if key_entry in result_list:
if type(result_list[key_entry]) != list:
result_list[key_entry] = [result_list[key_entry]]
result_list[key_entry].append(je_name)
else:
result_list[key_entry] = je_name
return result_list
Background on project: It's a simple dictionary programme for a local language.
Dictionary iterates through rows of a csv file, which contain the English term, the word class and the target language term.
This function is called when the search function is called, to return a dictionary containing entries which match the searched term.
The search box works with a Tkinter entry and a button. When the button is pressed, it calls a def search(), which then gets the search term and uses the find_cell_en function to get the dictionary of items (result_list).
It works the first time it's used, returning the dictionary properly. However, if I then clear the search box and do a new search, it does successfully get to the find_cell_en function, but then skips the for loop (thereby not returning result_list)
Any help would be greatly appreciated