def subStringMatchExact(target,key):
    x=0
    start=()
    while target.find(key,x,)>=0:
        start=start+(target.find(key,x,),)
        x=(target.find(key,x,))+1
    return start

def constrainedMatchPair(firstMatch,secondMatch,lenght):
    n=()
    for x in range(0,len(firstMatch)):
        for y in range(0,len(secondMatch)):
            if int(firstMatch[x])+lenght+1==int(secondMatch[y]):
                n=n+(int(firstMatch[x]),)
    return n

def subStringMatchExactlyOne(target,key):
    exactlyone=subStringMatchExact(target,key)
    key1tuple=()
    key2tuple=()
    uptoone=()
    for z in range(0,len(key)):
        key1 = key[0:z]
        key1tuple=key1tuple+(key1,)
        key2 = key[z+1:]
        key2tuple=key2tuple+(key2,)
    for x in range(len(key)):
        uptoone=uptoone+(constrainedMatchPair(subStringMatchExact(target,key1tuple[x]),subStringMatchExact(target,key2tuple[x]),len(key1tuple[x])),)   
    uptoonebetter=()
    for x in range(len(uptoone)):
        uptoonebetter=uptoonebetter+uptoone[x]
    answer=()
    for x in uptoonebetter:
        if x not in exactlyone:
            answer=answer+(x,)
    return answer

Add a code snippet to your website: www.paste.org