Write a program to compare two strings if they are anagram are ...not through user defined function?

def sayan_anagram(str1, str2):

str1 = str1.replace(" ", "").lower()
str2 = str2.replace(" ", "").lower()


str1 = ''.join(sorted(str1))
str2 = ''.join(sorted(str2))


if str1 == str2:
    return True
else:
    return False

str1 = input("Enter first string: ")
str2 = input("Enter second string: ")

result = sayan_anagram(str1, str2)

if result:
print(“The two strings are anagrams.”)
else:
print(“The two strings are not anagrams.”)

1 Like

@sayanalu9091

Correct, keep it up.