Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

check if two strings are anagrams python

if sorted(s1) == sorted(s2): 
	print("The strings are anagrams.") 
else: 
	print("The strings aren't anagrams.")  
Comment

python find if strings are anagrams

def anagram_checker(first_value, second_value):
    if sorted(first_string) == sorted(second_string):
        print("The two strings are anagrams of each other.")
        out = True
    else:
        print("The two strings are not anagrams of each other.")
        out = False
    return out
        

first_string = input("Provide the first string: ")
second_string = input("Provide the second string: ")
anagram_checker(first_string, second_string)

Print(anagram_checker("python", "typhon"))
True
Comment

two strings are anagram or not check python

// for 2 strings s1 and s2 to be anagrams
// both conditions should be True
// 1 their length is same or 
len(s1)==len(s2)
// 2 rearranging chars alphabetically make them equal or 
sorted(s1)==sorted(s2)
Comment

PREVIOUS NEXT
Code Example
Python :: python line_profiler 
Python :: pandas drop row from a list of value 
Python :: install python 3.6 dockerfile 
Python :: delete database entry using name django 
Python :: django set random password 
Python :: python efficiently find duplicates in list 
Python :: python tkinter colored line 
Python :: outliers removal 
Python :: otp generation in python 
Python :: # How to Prints the current working directory in python 
Python :: python logging into two different files 
Python :: first column of a dataframe python 
Python :: generate unique id from given string python 
Python :: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel(). y = column_or_1d(y, warn=True) 
Python :: pandas group by day 
Python :: how to import from parent directory 
Python :: pandas two dataframes equal 
Python :: how to play mp3 files using vlc python library 
Python :: pandas where 
Python :: how to detect when a key is pressed in pygame 
Python :: difference between two dictionaries python 
Python :: best python ide for ubuntu 
Python :: python slicing multi dimensional array 
Python :: how to merge two dictionaries in python 
Python :: add column to existing numpy array 
Python :: python for loop one line 
Python :: python acf and pacf code 
Python :: checkbutton tkinter example 
Python :: python pyowm 
Python :: add one row to dataframe 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =