Answers for "anagram"

8

anagram python

def isAnagram(A,B):
  if sorted(A) == sorted(B):
    print("Yes")
  else:
    print("No")
isAnagram("earth","heart") #Output: Yes

#Hope this helps:)
Posted by: Guest on February-21-2021
1

anagram

#take user input
String1 = input('Enter the 1st string :')
String2 = input('Enter the 2nd string :')
#check if length matches
if len(String1) != len(String2):
    #if False
    print('Strings are not anagram')
else:
    #sorted function sort string by characters
    String1 = sorted(String1)
    String2 = sorted(String2)
    #check if now strings matches
    if String1 == String2:
        #if True
        print('Strings are anagram')
    else:
         print('Strings are not anagram')
Posted by: Guest on May-19-2021
0

Anagram

const anagram = (str1, str2) => {
    return str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
};

let test = anagram('Regallager', 'Lagerregal');
console.log(test);
Posted by: Guest on July-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language