sunny sunny - 3 months ago 7
Python Question

How to determine whether a substring is in a different string

I have a sub-string:

substring = "please help me out"


I have another string:

string = "please help me out so that I could solve this"


How do I find if
substring
is a subset of
string
using Python?

Answer

with in: substring in string:

>>> substring = "please help me out"
>>> string = "please help me out so that I could solve this"
>>> substring in string
True