Program to determine whether two strings are the anagram or not !

str1 = input("enter the first string");  
str2 = input("enter the second string");

#Checking for the length of strings  

if(len(str1)!= len(str2)):  
    print ("Both the strings are not anagram");  
else:  
    #Converting the strings to lower case  
    str1 = str1.lower();  
    str2 = str2.lower();  
    #Sorting the strings  
    str1 = ''. join(sorted(str1));  
    str2 = ''. join(sorted(str2));  
      
    if (str1 == str2):  
        print ("Both the strings are anagram");   
    else:  
        print ("Both the strings are not anagram");

input: str1= "Elbow";

str2 = "Below";

output : both the strings are anagram.

Posted on by