Форум сайта python.su
I have line ‘pythonpythonpyth’. How do I know which word is the foundation line?.
Other examples:
“hellohellohellohello” –> hello
“DOLORIUMD” –> DOLORIUM
“HELLOL” –> HELLOL
“thewordword” –> thewordword
I need to know whether the word in the text is repeated and get it. This will be the key.
Офлайн
>>> def f(s): ... i = s.find(s[0], 1) ... return (i > 0 and s[:i]) or s ... >>> f('hellohellohellohello') 'hello' >>> f('DOLORIUMD') 'DOLORIUM' >>> f('HELLOL') 'HELLOL' >>> f('thewordword') 'thewordword' >>>
Отредактировано py.user.next (Ноя. 5, 2014 22:46:13)
Офлайн