I thing this work: 

stg='pythonpython' 
foundationline=stg[ 0:( stg [ 1: ].index( stg[ 0 ])+1 ) ] 

On 2014-11-05 11:58, lordvita...@gmail.com wrote: 
> I have line 'pythonpythonpyth'. How do I know which word is the foundation 
> line?. 
> Other examples: 
> "pythonpythonpyth" is python 
> "DOLORIUMD" is DOLORIUM 
> "HELLOLHELLO" is HELLOL 
> "thewordword" is thewordword 
> 
> I need to know whether the word in the text is repeated and get it. This will 
> be the key. 
> 
Consider the first example. 

If the foundation is the first 1 character 'p' and you repeat it enough 
times you'll get 'pppppppppppppppp'. 

This is the same length as the line. 

Does it match the line? No. 

OK. 

If the foundation is the first 2 characters 'py' and you repeat it 
enough times you'll get 'pypypypypypypypy'. 

This is the same length as the line. 

Does it match the line? No. 

OK. 

If the foundation is the first 3 characters 'py' and you repeat it 
enough times you'll get 'pytpytpytpytpytpyt'. 

This is longer than as the line, so truncate it to 'pytpytpytpytpytpy'. 

Does it match the line? No. 

OK. 

Continue in this vein until you'll get a match. (The foundation might 
in fact be the entire line.) 

-- 
https://mail.python.org/mailman/listinfo/python-list 

III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero del 
2014. Ver www.uci.cu
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to