<jupyter_start><jupyter_text>All the IPython Notebooks in this **Python Examples** series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/90_Python_Examples)**  Python Program to Check If Two Strings are AnagramIn this example, you will learn to check if two strings are anagram.To understand this example, you should have the knowledge of the following Python programming topics:To understand this example, you should have the knowledge of the following **[Python programming](https://github.com/milaan9/01_Python_Introduction/blob/main/000_Intro_to_Python.ipynb)** topics:* **[Python Strings](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String.ipynb)**Two strings are said to be anagram if we can form one string by arranging the characters of another string. For example, Race and Care. Here, we can form Race by arranging the characters of Care.<jupyter_code># Example 1: check if two strings are anagrams using sorted()

str1 = "Heart"
str2 = "Earth"

# 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.")

'''
>>Output/Runtime Test Cases:
     
heart and earth are anagram.
'''<jupyter_output>heart and earth are anagram.
{'fraction_non_alphanumeric': 0.1025, 'fraction_numerical': 0.0225, 'mean_word_length': 4.249180327868852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '616715', 'license': 'MIT', 'n_tokens_mistral': 513, 'n_tokens_neox': 486, 'n_words': 179, 'path': '02_Python_Datatypes_examples/033_check_if_two_strings_are_anagram.ipynb', 'repo_name': 'peterennis/90_Python_Examples', 'size': '1607'}