5

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'?

akobre01
  • 777
  • 1
  • 10
  • 22

1 Answers1

5

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-.

sacuL
  • 49,704
  • 8
  • 81
  • 106