Anagrams in Python || Python

 

In this we are going to see a program on how to calculate Anagrams in Python Programming Language.


def anagram(str1, str2):
    if len(str1) != len(str2):
        return False
    str1 = str1.replace(" ", "").lower()
    str2 = str2.replace(" ", "").lower()
    return sorted(str1) == sorted(str2)

print(anagram("listen", "silent"))

# Coded By DHIRAJ SHELKE

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post