Languages
[Edit]
EN

Python - check if string contains character

0 points
Created by:
Hiba-Tate
248

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

Quick solution:

text = "ABC"
print("B" in text)  # True

 

Practical example

In this example, we check if B character is present in the text string using in keyword.

text = "ABC"
if "B" in text:
    print("The 'B' character is present in the", text)

Output:

The 'B' character is present in the ABC

Python - string (popular problems)

Python - check if string contains character
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