Re: The longest word

2009-07-28 Thread NiklasRTZ
There were 3 solutions. Everybody's homework is someone's "what's this?" max('asdasfd faop29v8 asejrhjhw awg5w35g aw3g5aw3g kajhsdkfhlskjdhfakljsdhf awg3 aw3'.split(), key=len) sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),key=len)[-1] sorted("a AAA aa a vv".split(' '),lambda a,b: len

Re: The longest word

2009-07-28 Thread ryles
On Jul 28, 7:55 am, NiklasRTZ wrote: > Sincere thanks for strengthening python's superior flexibility. Same > function also works around an exploding index problem returning > results for longest word where otherwise a word with whitespace > crashes the index: Babelfish? -- http://mail.python.

Re: The longest word

2009-07-28 Thread NiklasRTZ
On Jul 28, 7:03 am, Hrvoje Niksic wrote: > Piet van Oostrum writes: > > >> NiklasRTZ (N) wrote: > > >>N> Thank you. This seems to work: > >>N> sorted("a AAA aa a  sdfsdfsdfsdf vv".split(' '),lambda a,b: len(a)- > >>N> len(b))[-1] > >>N> 'sdfsdfsdfsdf' > > > simpler: > > > sorted("a AAA a

Re: The longest word

2009-07-28 Thread Hrvoje Niksic
Piet van Oostrum writes: >> NiklasRTZ (N) wrote: > >>N> Thank you. This seems to work: >>N> sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),lambda a,b: len(a)- >>N> len(b))[-1] >>N> 'sdfsdfsdfsdf' > > simpler: > > sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '), key=len)[-1] There i

Re: The longest word

2009-07-28 Thread Peter Otten
NiklasRTZ wrote: > On Jul 28, 5:02 am, Bearophile wrote: >> On Jul 28, 10:26 am, NiklasRTZ wrote: >> >> > Newbie hello onwards to the .py manual asks meantime how the longest >> > word gets determined? >> > First word, ok >> > 'a aa aaa a

Re: The longest word

2009-07-28 Thread Piet van Oostrum
> NiklasRTZ (N) wrote: >N> Thank you. This seems to work: >N> sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),lambda a,b: len(a)- >N> len(b))[-1] >N> 'sdfsdfsdfsdf' simpler: sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '), key=len)[-1] -- Piet van Oostrum URL: http://pietvanoostru

Re: The longest word

2009-07-28 Thread Piet van Oostrum
occurs twice still naturally easier if >N> also occured just once. >N> Sincere thanks & regards >N> Niklas 1. Is this homework? 2. It sounds very confusing. Are you trying to find the longest word in a series of words seperated by spaces? find and rfind will not help you much.

Re: The longest word

2009-07-28 Thread NiklasRTZ
On Jul 28, 5:02 am, Bearophile wrote: > On Jul 28, 10:26 am, NiklasRTZ wrote: > > > Newbie hello onwards to the .py manual asks meantime how the longest > > word gets determined? > > First word, ok > >  'a aa aaa aa'[:'a aa aaa aa'.find(' &#

Re: The longest word

2009-07-28 Thread Bearophile
On Jul 28, 10:26 am, NiklasRTZ wrote: > Newbie hello onwards to the .py manual asks meantime how the longest > word gets determined? > First word, ok >  'a aa aaa aa'[:'a aa aaa aa'.find(' ',1,10)] Your language is not easy to understand, but I think you

The longest word

2009-07-28 Thread NiklasRTZ
Newbie hello onwards to the .py manual asks meantime how the longest word gets determined? First word, ok 'a aa aaa aa'[:'a aa aaa aa'.find(' ',1,10)] 'a' rfind is another subset >>> 'a aa aaa aa'[:'a aa aaa aa'.rfind('