To check two words / strings are same
def check_same_words(word1, word2):
if word1 == word2: return True else: return False # Example usage string1 = "hello" string2 = "hello" if check_same_words(string1, string2): print("The two words are the same.") else: print("The two words are different.") In this program, we define a function `check_same_words` that takes two words/strings as arguments. It compares the two words using the equality operator (`==`) and returns `True` if they are the same, and `False` otherwise.To use this program, you can assign your two words to the variables `string1` and `string2` and then call the `check_same_words` function passing in these variables as arguments. Finally, based on the return value of the function, you can print the appropriate message indicating whether the two words are the same or different.
Comments
Post a Comment