The in
operator is used to test the membership of a value in a sequence. When applied to a string, it checks whether a substring is present in the given string or not. Here's an example:
main.py107 chars6 lines
Output:
main.py17 chars2 lines
In the above example, we are checking if the substring "Hello" is present in the string s
. Since it is present, the if condition is satisfied and the corresponding message is printed.
gistlibby LogSnag