Hi!
Why a.sort() is equal with b.sort() all the time?
Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an array of all the anagrams or an empty array if there are none. For example:
anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']) => ['aabb', 'bbaa']
Why a.sort() is equal with b.sort() all the time?
words = ['aabb', 'abcd', 'bbaa', 'dada']
word = 'abba'
def anagram(word, words):
l = []
a = sorted(word)
for n in words:
b = sorted(n)
if a.sort() == b.sort():
l.append(n)
return l
print(anagram(word, words ))This is the problem:Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an array of all the anagrams or an empty array if there are none. For example:
anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']) => ['aabb', 'bbaa']
