Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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"))
Comment

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  
Comment

anagram python

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

#Hope this helps:)
Comment

finding anagrams in python

is_anagram = lambda x1, x2: sorted(x1) == sorted(x2)

print(is_anagram('silent','listen')) # True
print(is_anagram('elivs', 'dead')) # False
Comment

PREVIOUS NEXT
Code Example
Python :: get sum in range 
Python :: python to create pandas dataframe 
Python :: python numphy how to use fractions 
Python :: python color text 
Python :: is everything in python an object 
Python :: pandas df make set index column 
Python :: what is // in python 
Python :: pandas count number missing values 
Python :: set http response content type django 
Python :: remove duplicates function python 
Python :: np to tuple 
Python :: creating a virtual environment with django on windows 
Python :: python get file path from in os.walk 
Python :: python loop list from last to first 
Python :: multinomial regression scikit learn 
Python :: python dictionary to array 
Python :: write list to file python 
Python :: how to check if text is in upper case in python 
Python :: plt.legend( 
Python :: keras.layers.simplernn 
Python :: python check if class has function 
Python :: delete n from textpython 
Python :: scipy euclidean distance 
Python :: initialize dictionary to zero in python 
Python :: pandas select 2nd row 
Python :: how to clean environment python 
Python :: get number of rows pandas 
Python :: python read in integers separated by spaces 
Python :: append vs insert python 
Python :: get current data with python 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =