TECHIES WORLD

For Techs.... Techniques.... Technologies....

CpanelLinuxPython

How to check whether a string contains another string using Python

We can check whether a string contains another string using Python operator.

Let us discuss one example.

>>>str = "I have red pen"
>>> "red" in str
True
>>> "car" in str
False

It will give True if it contains the keyword and give False if not contains the keyword.

That's all…

Leave a Reply