I need to return the smallest average value of word similarities within a list (which I can do) but I don’t know how to assign a word string value to the average values, for example in a list ['my', 'bro', 'myline'] of course bro would have the least word comparison value and hence I need 'bro' to be returned along with the comparison value (which I already know how to…just need to know how to assign values within nested loops).
final_tup = ()
ave_list = []
for word in final_list:
word1 = word
sum = 0
for word in final_list:
word2 = word
if word2 != word1:
num = cossim(word1,word2)
sum = sum + num
average = float(sum/(len(final_list)-1))
ave_list.append(average)
1 Answer