In Python, you can compare two strings using the ==
operator for equality check.
In this example,
str1
and str2
with different values.==
operator.==
operator returns True
if the strings are equal, and False
otherwise.# Comparison of Strings in Python
str1 = 'Hello'
str2 = 'hello'
result = str1 == str2
print('Strings are equal:', result)
Strings are equal: False
In this tutorial, we learned How to Compare Two Strings in Python language with well detailed examples.