Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python check anangram

str1 = "Race"
str2 = "Care"

# convert both the strings into lowercase
str1 = str1.lower()
str2 = str2.lower()

# check if length is same
if(len(str1) == len(str2)):

    # sort the strings
    sorted_str1 = sorted(str1)
    sorted_str2 = sorted(str2)

    # if sorted char arrays are same
    if(sorted_str1 == sorted_str2):
        print(str1 + " and " + str2 + " are anagram.")
    else:
        print(str1 + " and " + str2 + " are not anagram.")

else:
    print(str1 + " and " + str2 + " are not anagram.")
Comment

PREVIOUS NEXT
Code Example
Python :: python os module using stat 
Python :: python two list into dictinaray list comprehension 
Python :: Using iterable unpacking operator * 
Python :: python Access both key and value using iteritems() Return keys or values explicitly 
Python :: display calendar 
Python :: how to use kite python 
Python :: python round function 
Python :: python downsample image 
Python :: travis deployment script for django applications to heroku 
Python :: spotify meist gespielte lieder sehen 
Python :: django rotatingfilehandler 
Python :: tf.get_variable initializer 
Python :: how to loop through glob.iglob iterator 
Python :: draw networkx graph using plt.pause 
Python :: python beacon 
Python :: pyAesCrypt 
Python :: tkinter lottery app 
Python :: numpy print full array to srdout 
Python :: plt.savefig no frame 
Python :: Access the Response Methods and Attributes in python Show redirections 
Python :: how to vreate a list in python 
Python :: python @property decorator 
Python :: Python - pasword hashed 
Python :: disable kivy button in kv 
Python :: how to add field to django forms createview 
Python :: .text xpath lxml 
Python :: How to make colors.winapp in WindowsAP 
Python :: Normalize basic list data 
Python :: simulieren mit python 
Python :: for con condicion 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =