HTML & JS
#function defination and declaration
def areAnagram(string1, string2):
    
    len1 = len(string1)
    len2 = len(string2)
    
    #Check if the lengths are same or not
    if len1 != len2:
        print("Not Anagram")
        
    #Sorting the strings
    string1 = sorted(string1)
    string2 = sorted(string2)
    
    #Comparing the strings
    for itr in range(0,len1):
        if string1[itr] != string2[itr]:
            print("Not Anagram")
            return
    
    print("Anagram")
    return

#driver code
str1 = "geekstocode"
str2 = "codegeeksto"

#function call
areAnagram(str1, str2)

Generated URL:

Output:

Anagram
Report Bug