the use of python to identify if two words contain the same letter

You are passing wrong arguments to the function.

Test.assert_equals(anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']), ['aabb', 'bbaa'] here you are passing the first parameter as a string. while the function expects a list. Change your code to: Test.assert_equals(anagrams(['abba'], ['aabb', 'abcd', 'bbaa', 'dada']), ['aabb', 'bbaa']

note that I have just passed ‘abba’ in a list, because your function expects it to be a list.

If you want to use your previous code, from your function change this line sorted_defaultword = sorted(word[0]) to sorted_defaultword = sorted(word)

And this should do the job…

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top