string equal in python code example
Example 1: string equals python
str1 == str2
# return True if the strings are equals. Case sensitive !
str1 = "python"
str2 = "python"
str1 == str2 # True
str1 = "python"
str2 = "javascript"
str1 == str2 # False
str1 = "python"
str2 = "PYTHON"
str1 == str2 # False
Example 2: determine how 2 string si equal py
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()