Jignesh Sutar wrote:

> #python2.7
> 
>>>> s="V01_1"
>>>> s.strip("_1")
> 'V0'
> 
> 
> Wouldn't you expect the result to be "V01" ?

str.strip() doesn't strip off a suffix or prefix; its first argument is 
interpreted as a character set, i. e. as long as s ends/starts with any of 
the characters "_" or "1", remove that.

If you want to remove a suffix you have to write

if suffix and s.endswith(suffix):
    s = s[:-len(suffix)]

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to