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

python anagram finder

def isAnagram(str1, str2):
    str1_list = list(str1)
    str1_list.sort()
    str2_list = list(str2)
    str2_list.sort()

    return (str1_list == str2_list)
Comment

How to check for Anagrams in python

from collections import Counter
def is_anagram(s1, s2):
  return Counter(s1) == Counter(s2)

s1 = 'listen'
s2 = 'silent'
s3 = 'runner'
s4 = 'neuron'

print(''listen' is an anagram of 'silent' -> {}'.format(is_anagram(s1, s2)))
print(''runner' is an anagram of 'neuron' -> {}'.format(is_anagram(s3, s4)))


# Output

# 'listen' an anagram of 'silent' -> True
# 'runner' an anagram of 'neuron' -> False
Comment

find anagrams of a string python

def are_anagrams(first, second):
    return len(first) == len(second) and sorted(first) == sorted(second)
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 :: python code to open an application 
Python :: how to launch a application using python 
Python :: python plot confidence interval 
Python :: django abstractuser fields 
Python :: how to do square roots in python 
Python :: wikipedia api python 
Python :: unban member using ID discord.py 
Python :: numpy shuffle along axis 
Python :: read file bytes python 
Python :: inline keyboard telegram bot python 
Python :: python if statements 
Python :: python / vs // 
Python :: python check if key exist in dict 
Python :: how to get percentage in python 
Python :: padding figures in pyplot 
Python :: python array use numpy arange 
Python :: selenium 
Python :: list unpacking python 
Python :: how to sort nested list in python 
Python :: sign python 
Python :: convert int to hexadecimal 
Python :: fraction in python 
Python :: show columns with nan pandas 
Python :: Simple example of python strip function 
Python :: python tuples 
Python :: iteration over dictionary 
Python :: python newton raphson 
Python :: df.info() in python 
Python :: how to append data in excel using python pandas 
Python :: python quiz answer stores 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =