# Is this not sufficient? def is_anagram( A , B ): return sorted( list( A ) ) == sorted( list( B ) )