Tag Archives: polymorphic operator

How to use the polymorphic operator in the find-and-count methods to search for a substring in Python

Let’s say that you want to search for a substring within a string object. Nothing easier. In Python, there is a polymorphic operator named in which allows you to do just that! Let’s try it!

>>> s1 = 'Dan is a web developer based within the EU.'
>>> 'Dan' in s1
True
>>> 'Dumitrache' in s1
False
>>> 'EU' in s1
True
>>> 'Canada' in s1
False

Continue reading