anagram program in python
def IsAnagram(string1,string2): lenth = len(string2) total = 0 for char in string1: if char in string2: total += 1 if total == lenth: return True return False print(IsAnagram("amd","madd"))
how to write a code for anagram in python
def anagramCheck2(str1,str2): # Convert string into lists list1 = list(str1) list2 = list(str2) # Sort the list value list1.sort() list2.sort() position = 0 matches = True while position < len(str1) and matches: if list1[position]==list2[position]: position = position + 1 else: matches = False return matches