I am comparing string similarity between 2 lists of strings and whenever the similarity function is >0 I loose the word2 value:
list1=['aaaa','cccc','bb']
list2=['aaa','fff','v']
for word1 in list1:
for word2 in list2:
if (similar(word1 ,word2)>0):
print(word2)
similar is Sequence Matcher:
def similar(a, b):
s= SequenceMatcher(a,b).ratio()
s=round(s*100,1)
return s
If the 'similar' function is>0 then my word2 becomes ''.
If i check for similar(word1,word2)==0 then my value stays right.
word2is astrobject then it's impossible that calling a function withword2as an argument will change the value ofword2:strobjects are immutable and functions can't rebind names in the caller's context. Ifword2is not astrobject, you need to explain what kind of object it is.