Compare the first with its only right neighbor
j = 0 NEW_LINE while ( j < min ( len ( a [ 0 ] ) - 1 , len ( a [ 1 ] ) - 1 ) ) : NEW_LINE INDENT if ( a [ 0 ] [ j ] == a [ 1 ] [ j ] ) : NEW_LINE INDENT j += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT ind = 0 NEW_LINE res [ ind ] = a [ 0 ] [ 0 : j + 1 ] NEW_LINE ind += 1 NEW_LINE