1def isAnagram(A,B):
2 if sorted(A) == sorted(B):
3 print("Yes")
4 else:
5 print("No")
6isAnagram("earth","heart") #Output: Yes
7
8#Hope this helps:)
1#take user input
2String1 = input('Enter the 1st string :')
3String2 = input('Enter the 2nd string :')
4#check if length matches
5if len(String1) != len(String2):
6 #if False
7 print('Strings are not anagram')
8else:
9 #sorted function sort string by characters
10 String1 = sorted(String1)
11 String2 = sorted(String2)
12 #check if now strings matches
13 if String1 == String2:
14 #if True
15 print('Strings are anagram')
16 else:
17 print('Strings are not anagram')
1const anagram = (str1, str2) => {
2 return str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
3};
4
5let test = anagram('Regallager', 'Lagerregal');
6console.log(test);