Python striping extra characters

I'm trying to understand what string.strip() in python is doing:

In [35]: t1 = '-MIN-North'

In [36]: t1.strip('-MIN-')
Out[36]: 'orth'

In [37]: t2 = '-MIN-north'

In [38]: t2.strip('-MIN-')
Out[38]: 'north'

Why is t1.strip('-MIN-') not equal to 'North' but t2.strip('-MIN-') equal to 'north'?

1 answer

  • answered 2018-10-09 16:25 sacul

    strip is taking out all the characters you provide it in the argument.

    In your first example, it is stripping out the N from North because N is in -MIN-.

    In the second, it is not stripping the n from north because n is not in -MIN-.