ค้นหาว่าอาร์เรย์มีสตริงที่ไม่ตรงกันหรือไม่

def check(list, s):
    n = len(list)
 
    # If the array is empty
    if (n == 0):
        return False
 
    for i in range(0, n, 1):
         
        # If sizes are same
        if (len(list[i]) != len(s)):
            continue
 
        diff = False
        for j in range(0, len(list[i]), 1):
            if (list[i][j] != s[j]):
 
                # If first mismatch
                if (diff == False):
                    diff = True
 
                # Second mismatch
                else:
                    diff = False
                    break
                 
        if (diff):
            return True
 
    return False
def check(sList,string):
    return any(len(string)==len(s) and sum(a!=b for a,b in zip(s,string))==1 
               for s in sList)

check(["abcd","cdef","efgh"],"xfgh") # True
check(["abcd","cdef","efgh"],"abdc") # False