Here I'm asking for a word, and generating a list of all combinations for the letters in word
variable, in theory (in my head) the for loop's if
statement should work.
from itertools import product
from string import ascii_lowercase
word = input("Enter a word, preferably short")
PossibleWithWordLetters = [''.join(i) for i in product(word, repeat = len(word))]
for a in PossibleWithWordLetters:
if word.count(word[i]) [for i in range(len(word))] == 1 and a in PossibleWithWordLetters:
print(a)
The aim of the program is to list all valid anagrams from a word inputted - and checked where it only contains one of each of the letters in word
- then i'll check this against a word file of real words - which I haven't got round to yet.
Any help is appreciated on getting the for
loop to work.