Notification texts go here Contact Us Click here

Python program that checks if two given strings are Anagrams of each other .

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

Program : Python program that checks if two given strings are Anagrams of each oth                     er 

 

def are_anagrams(str1, str2):
    return sorted(str1) == sorted(str2)
 
if __name__ == "__main__":
    string1 = input("Enter the first string: ").lower()
    string2 = input("Enter the second string: ").lower()
 
    if are_anagrams(string1, string2):
        print("The two strings are anagrams.")
    else:
        print("The two strings are not anagrams.")
 
OUTPUT :
Enter the first string: I Love You
Enter the second string: I Love You
The two strings are anagrams.
 
Enter the first string: hellopython
Enter the second string: HelloPython
The two strings are anagrams.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.