How to trim n characters from right end of a string?

Paul McGuire ptmcg at
Sun Jun 27 02:07:58 CEST 2004

"Robert" <nospam at> wrote in message
news:GUnDc.13670$OX2.9785 at
> Please tell this newbie how to remove n characters from the right end of a
> string.
> Thanks, Robert
At the Python '>>>' prompt:

>>> a = "This is a string."
>>> print a[:-5]
This is a st

More information about the Python-list mailing list