Answers for "anagram python"

3

python anagrams

# function to check if two strings are 
# anagram or not  
def check(s1, s2): 
      
    # the sorted strings are checked  
    if(sorted(s1)== sorted(s2)): 
        print("The strings are anagrams.")  
    else: 
        print("The strings aren't anagrams.")          
          
# driver code   
s1 ="listen"
s2 ="silent" 
check(s1, s2)
Posted by: Guest on May-13-2020
1

check if two strings are anagrams python

if sorted(s1) == sorted(s2): 
	print("The strings are anagrams.") 
else: 
	print("The strings aren't anagrams.")
Posted by: Guest on April-07-2020
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