Python Program to check two String are Anagram or not

Anagram


An anagram is a word or phrase that's formed by rearranging the letters of another word or phrase. For example, the letters that make up “A decimal point” can be turned into the anagram “I'm a dot in place.” ... “Dormitory” turns into the anagram “dirty room,”

Examples of anagram
"restful" = "fluster"
"funeral" = "real fun"
"adultery" = "true lady"
"customers" = "store scum"
"forty five" = "over fifty"


Python Program for Anagram String




s1=input("Enter the First String: ")
s2=input("Enter the Second String: ")
def anagramCheck(s1, s2):      
    if(sorted(s1)== sorted(s2)):
        print("The strings are anagrams.") 
    else:
        print("The strings aren't anagrams.")
anagramCheck(s1,s2)





Output
 

 1.
Enter the First String: restful

Enter the Second String: fluster


The strings are anagrams. 




2.
Enter the First String:hello

Enter the Second String: Hello


The strings
aren't anagrams.

Comments

Post a Comment

Popular posts from this blog

C program that contains a string XOR each character in this string with 0 ,127

Queue in Data Structure(DS)

Implementation of stack Using Array