To check if two strings are equal ignoring case in Python, you can convert both strings to lowercase or uppercase using the lower()
or upper()
methods and then compare them.
In this example,
str1
and str2
with different cases, such as "Hello"
and "hello"
.lower()
or upper()
methods.==
operator.True
if the strings are equal ignoring case, and False
otherwise.# Equality Check Ignoring Case in Python
str1 = "Hello"
str2 = "hello"
result = str1.lower() == str2.lower()
print(f"Strings are equal ignoring case: {result}")
Strings are equal ignoring case: True
In this tutorial, we learned How to check if Two Strings are Equal ignoring case in Python language with well detailed examples.