How to check if a string contains a substring in Python
The most straightforward way to check if a string contains a substring is to use in (opens new window). You can also use find (opens new window) or index (opens new window) to get the position of the substring you're looking for. If the substring doesn't exist, you'll get a -1
.
Python
Copy code