Doctest failing

Terry Reedy tjreedy at
Sat Sep 10 15:36:47 EDT 2011

On 9/10/2011 7:47 AM, Peter Otten wrote:

> You can work around that with a
> flag along these lines
> first = True
> for word in title_split:
>      if first:
>          # special treatment for the first word
>          first = False
>      else:
>          # put checks for all words but the first here
>      new_title.append(fixed_word) # assuming you have stored the titlecased
>                                   # or lowercased word in the fixed_word
>                                   # variable

An alternative to a flag and testing every item is to remove and process 
the first item *before* the loop. See my response on this thread or my 
new thread
Idioms combining 'next(items)' and 'for item in items:'

Terry Jan Reedy

More information about the Python-list mailing list