A Python function that checks if two strings are anagrams by comparing their sorted characters. The is_anagram function returns True for "listen" and "silent", False when paired with "run".
Chapters
Let's create a Python program to check if the given string is anagram of another string or not. So here I am creating a function called is_anagram, passing two parameters s1 and s2, returning sorted, which is— should be equal to equal to s2 sorted. So here I am creating two strings. s1 is a variable in which I am storing listen, s2 I am storing silent, which I am testing it with the print statement passing s1 comma s2. It should print true for us. Yes, it is true. Now I am changing another string to run. It should give us false. So when I press the run button, I am getting false as an output.