backreference

Peter Hansen peter at engcorp.com
Sat Jan 11 22:20:46 CET 2003


Cousin Stanley wrote:
> 
> Would a simple non-re version work ???
> 
> list_lines = [ 'Greetings, huMon.' ,
>                'How are you today?' ,
>                'I hope you are OK;' ,
>                'Python rocks!' ,
>                'Check the following:' ]
> 
> for xLine in list_lines :
> 
>     last_char = xLine[ len( xLine ) - 1 : ]
> 
>     xStr = xLine[ : -1 ]
> 
>     print xStr , last_char

I'm pretty sure his example would require you to separate
out the "," in "Greetings, huMon." as well as the final
characters (and the final characters only if they are
punctuation).




More information about the Python-list mailing list