The longest word
Piet van Oostrum
piet at cs.uu.nl
Tue Jul 28 11:24:37 CEST 2009
>>>>> NiklasRTZ <niklasro at gmail.com> (N) wrote:
>N> Newbie hello onwards to the .py manual asks meantime how the longest
>N> word gets determined?
>N> First word, ok
>N> 'a aa aaa aa'[:'a aa aaa aa'.find(' ',1,10)]
>N> rfind is another subset
>>>>> 'a aa aaa aa'[:'a aa aaa aa'.rfind(' ',1,10)]
>N> 'a aa aaa'
>N> One row should be able. It's a direct word 'a aa aaa...' and can be a
>N> variable, it's no big deal it occurs twice still naturally easier if
>N> also occured just once.
>N> Sincere thanks & regards
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. You should start with var.split() if var contains the text.
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list