'''
Created on Oct 6, 2016

@author: Susan
'''
def positionDuplicate(phrase):
    words = phrase.split()
    if len(words)< 2: 
        return -1
    pos = 0
    while True:
        if pos == len(words)-1:
            return -1 # didn't find it
        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)
 
