Problem: We need to write a program in python to check whether the two given numbers are Anagram or not.

What is an Anagram

An anagram is any word which can be used to form another word by rearranging the letters of the original word.

Examples

  • Tar <=> Rat
  • Arc <=> Car
  • Elbow <=> Below
  • State <=> Taste
  • Cider <=> Cried
  • Dusty <=> Study

Let see the python program to check anagram word.

Recommended:

Output

Explanation

The two words can only be anagram if they are meaningful and are compromised of the same letters. So we are taking two words as inputs (already defined in our case), and sorting it with the help of inbuilt sorted() method. After sorting the words we are comparing them whether they are same or not. If yes then the word combination is an anagram.

E.g

Input – act , cat
Sorted – act, act

Both are the same/equal so they are an anagram.

If you have any doubts or suggestion then comment below.

Leave a Reply

Close Menu