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