I'm coding a function in python, which is supposed to return the differents anagrams of a word. But when I test it, the function returns me none. Could you help me please ? Thank you very much ;)
My code :
import random
def factorial(number):
result = 1
for i in range(1, number + 1):
result *= i
return result
def find_anagrams(word):
letters = []
anagramms = []
for letter in word:
letters.append(letter)
possibilities = factorial(len(letters))
tries = 0
while tries < possibilities:
random.shuffle(letters)
new_word = letters[0]
for i in range(1, len(letters)):
new_word += letters[i]
if new_word not in anagramms:
anagramms.append(new_word)
tries += 1
print(find_anagrams("hello"))