'''
Created on Oct 11, 2017

@author: Susan
'''
def positionDuplicate(phrase):
    words = phrase.split()
    if len(words)< 2: 
        return -1
    pos = 0
    while True:
        if pos + 1 == len(words):
            pos = -1
            break
        if words[pos] == words[pos+1]:
            break
        pos = pos+1
    return pos  
 

if __name__ == '__main__':
    print 
    print "output from positionDuplicate"
    phrase = "this is a a test ok"
    print phrase, positionDuplicate(phrase)
    phrase = "yes no yes no yes no"
    print phrase, positionDuplicate(phrase)
    phrase = "why oh why oh oh"
    print phrase, positionDuplicate(phrase)
    phrase = "a a" 
    print phrase, positionDuplicate(phrase)
    phrase = "a b c c" 
    print phrase, positionDuplicate(phrase)
 
