3
rea
のようなひどい文字を含む単語から有効な英語の単語を生成しようとしています。era
、ear
、are
のように配置することができます。 私はこの試みている:SCOWL here:ここリストの要素を.txtファイルで検索するには?
from itertools import permutations
usr_input = input('your word:')
permuted_list = [''.join(p) for p in permutations(usr_input)] #list of
all possible permutation of user entered word
count=0
for word in permuted_list:
if word in open('wordlist.txt').read():
print(word)
count+=1
print(count)
を、wordlist.txt
は、ソースから設定された有効英単語データです。
私の問題は、有効なものの代わりにすべての並べ替えを表示することです。