Anagram Program in Python

In this tutorial, you will learn the writing program in to check string is anagrams or not in Python.

Read This : What is Anagram? Write an anagram program in C. 

How this Python program will behave?

This Python Program will take two String from user as an input. And after the comparison of two input string, program will return output.

If the string is anagram then Program will return “Given Strings are anagram”.

And if Strings are not anagram then it will return “Strings are not anagram”.

Anagrams program in Python

def anagramCheck(str1, str2):
    if (sorted(str1) == sorted(str2)) :  
	    return True 
    else :  
	    return False 
str1 = input("Please enter String 1 : ")
str2 = input("Please enter String 2 : ")
if anagramCheck(str1,str2):
    print("Anagram")
else:
    print("Not an anagram")
 

Output:

anagram program in c