Languages
[Edit]
EN

Python - custom string contains() method

0 points
Created by:
Teilsa
1315

In this article, we would like to show you how to check if the string contains a substring in Python.

Quick solution:

 

Practical example

Edit

In this example, we use in operator to create a custom implementation of the string contains() method and check if text contains some words.

Output:

Note:

You can also use string.find() method to find index of the specified substring.

Alternative titles

  1. Python - string contains substring (custom implementation)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Python - string (popular problems)

Python - custom string contains() method
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join