Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python striping extra characters [duplicate]

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

like image 667
akobre01 Avatar asked Oct 09 '18 16:10

akobre01


1 Answers

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

like image 69
sacuL Avatar answered Oct 23 '22 06:10

sacuL