<prompt> Write a function in any programming language to check if two words are anagrams of each other.  <response>: Here is a function in Python that can check if two words are anagrams of each other:pythondef are_anagramsword1, word2: Check if the lengths of the two words are equal if lenword1 ! lenword2: return False Sort the letters in the two words and compare them if sortedword1 sortedword2: return True else: return FalseThis function takes in two words as input and checks if they are anagrams of each other. First, it checks if the lengths of the two words are equal, since anagrams must have the same number of letters. If the lengths are not equal, the function returns False. If the lengths are equal, the function sorts the letters of both words and compares the two. If the sorted letters are equal, then the two words are anagrams and the function returns True. If the sorted letters are not equal, then the function returns False. 