Your approach to finding anagrams is perfectly reasonable. Sorting the words and comparing them is the easiest way to find if two words are anagrams of one another.
However, I think you're confused by the idea of function parameters. When you define
foo(x1, x2)
when foo is called, it is expected to be called with 2 parameters. You define
anagram(s1, s2)
but never supply it with s1 and s2. The parameter list is not a list of variable names that you use in the function -- you can assign new variables at will. Instead, it is the list of inputs that the function takes.
so, anagram() is incorrect. You need to call anagram(input1, input2). (Assuming you don't have default values, which I won't get into.
def isAnagram(s1, s2):
sortedWord1 = sorted(s1) # s1 is word1! (sorted instead of sort, strings are immutable)
#what should you do here?
if sortedWord1 == sortedWord2:
print("This is an anagram")
else:
print("This is not an anagram") # you forgot a closing quote!
word1 = input("Enter a string: ")
word2 = input("Enter a second string: ")
isAnagram(word1, word2)
I changed your code very slightly such that it should do the right thing. I recommend that you read up on functions a bit more before you continue, though.
Think of them just like functions in math! f(x) is meaningful, f, while still meaningful, is probably not what you were looking for.
>>> isAnagram("anagram", "nagaram")
This is an an anagram
>>> isAnagram("anagram", "woohoo")
This is not an anagram
>>> isAnagram("a", "a")
This is an an anagram