<doocs>0243.Shortest Word Distance_1.py
def shortestDistance( wordsDict: List[str], word1: str, word2: str) -> int:
    i1 = i2 = -1
    shortest_distance = len(wordsDict)
    for i in range(len(wordsDict)):
        if wordsDict[i] == word1:
            i1 = i
        elif wordsDict[i] == word2:
            i2 = i
        if i1 != -1 and i2 != -1:
            shortest_distance = min(shortest_distance, abs(i1 - i2))
    return shortest_distance
def sample_funcname ( var_0 : List [ str ] , var_3 : str , var_4 : str ) -> int :
    var_8 = var_6 = - 1
    var_10 = len ( var_0 )
    for var_12 in range ( len ( var_0 ) ) :
        if var_0 [ var_12 ] == var_3 :
            var_8 = var_12
        elif var_0 [ var_12 ] == var_4 :
            var_6 = var_12
        if var_8 != - 1 and var_6 != - 1 :
            var_10 = min ( var_10 , abs ( var_8 - var_6 ) )
    return var_10
