You can check if one string is a substring of another string in Python using the in
keyword. Here's an example:
main.py170 chars8 lines
Output:
main.py34 chars2 lines
In this example, we check if string2
is a substring of string1
using the in
keyword. Since string2
is indeed a part of string1
, the output is "string2 is a substring of string1".
gistlibby LogSnag