Created by Michael MrozekLinked to 5.5m issues across 90 teams
You can use the in
operator to check if a string contains a substring. To do this, you can use the following syntax:
if "substring" in somestring:
This will return True
if the substring is found in the string, and False
if it is not. For example, if you wanted to check if the string somestring
contains the substring example
, you would write:
if "example" in somestring:
If the substring is not found, you can use the continue
statement to move on to the next iteration of the loop. For example:
if "example" not in somestring: continue
Contributor
Teams
90