EN
Python - check if string doesn't contain character
0 points
In this article, we would like to show you how to check if string doesn't contain character in Python.
Quick solution:
xxxxxxxxxx
1
text = "ABC"
2
print("D" not in text) # True
In this example, we check if D
character is NOT present in the text
string using in
keyword.
xxxxxxxxxx
1
text = "ABC"
2
if "D" not in text:
3
print("The 'D' character isn't present in the", text)
Output:
xxxxxxxxxx
1
The 'D' character isn't present in the ABC