Q:

python print max line fuzzy ratio from a file

I am trying a python code,to find the maximum fuzzy ratio of all the line in the text file with the word 'good',the line having the max fuzzy ratio will be printed.I tried a program :
from fuzzywuzzy import fuzz
from collections import defaultdict
with open(qwer.txt, 'r') as my_file:
     for line in my_file:
        for part in line.split():
          a=line
          b='good'
          fuzziness = fuzz.ratio(a,b)
          filenames2fuzz[line].append(fuzziness)

    best_fuzziness_ratio = 0 
    for k, v in filenames2fuzz.items():
        if max(v) > best_fuzziness_ratio:
            best_fuzzy_line = k
            best_fuzziness_line_ratio = max(v)

    print(best_fuzzy_line)

Example:
qwer.txt has 1000+ lines
.................
I love God
he is a goody boy
.............

Output:
he is a goody boy

Please help me to get the output

A:

A short solution will probably be of this form:
def good_ratio(a):
    return fuzz.ratio(a, 'good')

with open('qwer.txt', 'r') as my_file:
    print(max(my_file, key=good_ratio))

or even shorter
with open('qwer.txt', 'r') as my_file:
    print(max(my_file, key=lambda a: fuzz.ratio(a, 'good')))

