'Why unable to find best match using fuzzywuzzy in this situation?

I have two lists, and I am trying to iterate each items one by one to find the first best match that is more than a certain threshold and stop. The lists are:

lista = ['okok', 'haha']
listb = ['ahah', 'ko']

Here is my code:

from fuzzywuzzy import fuzz

def f(lista, listb):
  for a in lista: 
    for b in listb:
        if fuzz.token_set_ratio(a, b) > 50:
          return (b)
        else:
          return ("sorry")
          continue

print(f(lista, listb))

But the result I get is "sorry". Note: I hope to maintain this if...else loop structure. Many Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source