String splitting question

Thomas Guettler pan-newsreader at thomas-guettler.de
Wed Apr 9 04:19:46 EDT 2003


On Wed, 09 Apr 2003 10:03:11 +0200, Max M wrote:

> William Park wrote:
>> Jim Shady <iamshady at rediffmail.com> wrote:
> 
>>>abcd/df/a/iiwk/abcdefghijkl/b/c
>>>
>>>I need to get the longest string between the /s of the string. 

[cut]

> s = 'abcd/df/a/iiwk/abcdefghijkl/b/c' print max([(len(sub), sub) for sub in s.split('/')])[-1]

looks like perl

 thomas

-- 
Thomas Guettler <guettli at thomas-guettler.de>
http://www.thomas-guettler.de




More information about the Python-list mailing list