'str' object has no attribute 'sort'
<p>I am quite new to python and was wondering if someone could help me fix a problem. Im making an anagram checker and have run into an issue. </p>

<pre><code>def anagram():
    worda = input("Please choose your first word:")     
    wordb = input("Please choose your second word:")
    if worda.isalpha():
        print((worda),"is a word")
    else:
        print((worda),"is not a word, please try again")      
        anagram()
    if wordb.isalpha():
        print((wordb),"is a word")         
    else:
        print((wordb),"is not a word,please try again")
        anagram()
    worda.sort
    wordb.sort    

anagram()
</code></pre>

<p>I get the error: AttributeError: 'str' object has no attribute 'sort'when I try to run it. </p>

<p>strings in Python are immutable, so it would make no sense for them to have a <code>sort</code> method, what you can do is use <code>sorted(worda)</code>, which returns a sorted list made out of the characters of the string.</p>

<p>Then to get a string back again, you can use <code>''.join(sorted(worda))</code></p>

python