<qiyuangong>243_Shortest_Word_Distance_2.py
def shortestDistance( words, word1, word2):
    index1 = index2 = -1
    res = len(words)
    for index, word in enumerate(words):
        if word1 == word:
            index1 = index
        elif word2 == word:
            index2 = index
        if index1 != -1 and index2 != -1:
            res = min(res, abs(index1 - index2))
    return res
def sample_funcname ( var_0 , var_1 , var_2 ) :
    var_5 = var_3 = - 1
    var_7 = len ( var_0 )
    for var_9 , var_10 in enumerate ( var_0 ) :
        if var_1 == var_10 :
            var_5 = var_9
        elif var_2 == var_10 :
            var_3 = var_9
        if var_5 != - 1 and var_3 != - 1 :
            var_7 = min ( var_7 , abs ( var_5 - var_3 ) )
    return var_7
