0

リストの要素を結合して、要素が特定の単語の 1 つを構成しているかどうかを確認するにはどうすればよいですか? 単語を構成しないすべての要素を削除し、それらを空白に置き換えます。初心者なのでお手柔らかにお願いします。

助けに感謝します。

私のコード:

def looking_word_left_to_right(the_list):
    for any_words in the_valid_words:
        for every in the_list:
            for letters_s in every:
                index_list=0

有効な単語 : ツチブタ アルバトロス アリゲーター アルマジロ バラクーダ ラクダ カリブー 猫 牛 シャモア ニワトリ タラ 鹿 恐竜 犬 ドッグフィッシュ ドッタール トンボ ウナギ フェレット フィンチ 魚 フラミンゴ フライ ゴールドフィンチ ドラゴン カワウソ 牛 鹿

リスト = ['e', 'l', 'l', 'e', 'z', 'a', 'g', 'c', 'h', 'i', 'c', 'k ', 'e', 'n', 'b', 'n', 'd', 'o'] ['d', 'e', 't', 'b', 'a', 'l' 、「l」、「i」、「g」、「a」、「t」、「o」、「r」、「a」、「a」、「a」、「o」、「l」] [ 'm'、'e'、'z'、'n'、'a'、'c'、'a'、't'、't'、'l'、'e'、'e'、'b ', 'l', 'r', 'c', 't', 'a'] ['c', 'f', 'e', 'n', 'a', 'r', 'c' 、「e」、「s」、「s」、「s」、'a', 'd', 'l', 'r', 'i', 't', 'f'] ['h', 'f', 't', 'r', 'a', ' r'、'r'、's'、's'、'o'、's'、'a'、'o'、'i'、'a'、'r'、'e'、'f' ] ['a', 'a', 'r', 'e', 'p', 'p', 'o', 'h', 's', 's', 'a', 'r', 'g', 'h', 'c', 'e', 'r', 'u'] ['m', 'r', 'h', 'e', 'i', 'r', ' m', 'm', 'w', 'i', 'l', 'd', 'f', 'c', 'u', 'm', 'e', 'b'] ['o '、'私'、'm'、'l'、't'、'a'、'a'、'i'、'r'、'f'、'o'、'v'、'i'、'n'、'd'、'a'、'l' , 'b'] ['i', 'g', 'l', 'a', 'l', 'o', 'b', 'e', 'h', 'o', 'e', 'a', 's', 'i', 'a', 'x', 'u', 'e'] ['s', 'a', 'b', 'l', 'd', ' i'、'n'、'b'、'b'、'c'、'c'、'r'、'h'、'h'、'r'、't'、'y'、'l' ] ['r', 'l', 'a', 'h', 's', 'i', 'f', 'd', 'l', 'o', 'g', 'k', 「r」、「c」、「t」、「l」、'a', 'i'] ['a', 'r', 'e', 'o', 'g', 'o', 'l', 'd', 'f', 'i', ' n', 'c', 'h', 'e', 'f', 'n', 'n', 'd'] ['d', 'm', 'n', 'e', 'e '、'p'、'o'、'l'、'e'、't'、'n'、'a'、'r'、'n'、't'、'a'、'd'、 'o'] ['d', 'i', 'n', 'o', 's', 'a', 'u', 'r', 'o', 'x', 'o', ' f', 'o', 'e', 'c', 'l', 'i', 'c'] ['t', 'n', 'a', 'h', 'p', 'e '、'l'、'e'、'p'、'a', 'l', 'g', 'a', 'i', 'e', 'r', 'h', 'o'] ['h', 'c', 'a', 'o' ', 'r', 'k', 'c', 'o', 'c', 'y', 'a', 't', 'r', 'm', 'o', 'a', 'c', 'r'] ['f', 'l', 'a', 'm', 'i', 'n', 'g', 'o', 'e', 'r', ' e', 'f', 'a', 'f', 'l', 'o', 'e', 'c'] ['h', 'a', 't', 'e', 'e '、'h'、'c'、'h'、'd'、'r'、'a'、'c'、'a'、'r'、'i'、'b'、'o'、 'う']'i', 'e', 'r', 'h', 'o'] ['h', 'c', 'a', 'o', 'r', 'k', 'c', ' o', 'c', 'y', 'a', 't', 'r', 'm', 'o', 'a', 'c', 'r'] ['f', 'l '、'a'、'm'、'i'、'n'、'g'、'o'、'e'、'r'、'e'、'f'、'a'、'f'、 'l', 'o', 'e', 'c'] ['h', 'a', 't', 'e', 'e', 'h', 'c', 'h', ' d'、'r'、'a'、'c'、'a'、'r'、'i'、'b'、'o'、'u']'i', 'e', 'r', 'h', 'o'] ['h', 'c', 'a', 'o', 'r', 'k', 'c', ' o', 'c', 'y', 'a', 't', 'r', 'm', 'o', 'a', 'c', 'r'] ['f', 'l '、'a'、'm'、'i'、'n'、'g'、'o'、'e'、'r'、'e'、'f'、'a'、'f'、 'l', 'o', 'e', 'c'] ['h', 'a', 't', 'e', 'e', 'h', 'c', 'h', ' d'、'r'、'a'、'c'、'a'、'r'、'i'、'b'、'o'、'u']「a」、「o」、「r」、「k」、「c」、「o」、「c」、「y」、「a」、「t」、「r」、「m」、「o」 ', 'a', 'c', 'r'] ['f', 'l', 'a', 'm', 'i', 'n', 'g', 'o', 'e' , 'r', 'e', 'f', 'a', 'f', 'l', 'o', 'e', 'c'] ['h', 'a', 't', 「e」、「e」、「h」、「c」、「h」、「d」、「r」、「a」、「c」、「a」、「r」、「i」、「b」 '、'o'、'u']「a」、「o」、「r」、「k」、「c」、「o」、「c」、「y」、「a」、「t」、「r」、「m」、「o」 ', 'a', 'c', 'r'] ['f', 'l', 'a', 'm', 'i', 'n', 'g', 'o', 'e' , 'r', 'e', 'f', 'a', 'f', 'l', 'o', 'e', 'c'] ['h', 'a', 't', 「e」、「e」、「h」、「c」、「h」、「d」、「r」、「a」、「c」、「a」、「r」、「i」、「b」 '、'o'、'u']'c', 'r'] ['f', 'l', 'a', 'm', 'i', 'n', 'g', 'o', 'e', 'r', ' e', 'f', 'a', 'f', 'l', 'o', 'e', 'c'] ['h', 'a', 't', 'e', 'e '、'h'、'c'、'h'、'd'、'r'、'a'、'c'、'a'、'r'、'i'、'b'、'o'、 'う']'c', 'r'] ['f', 'l', 'a', 'm', 'i', 'n', 'g', 'o', 'e', 'r', ' e', 'f', 'a', 'f', 'l', 'o', 'e', 'c'] ['h', 'a', 't', 'e', 'e '、'h'、'c'、'h'、'd'、'r'、'a'、'c'、'a'、'r'、'i'、'b'、'o'、 'う']、「d」、「r」、「a」、「c」、「a」、「r」、「i」、「b」、「o」、「u」]、「d」、「r」、「a」、「c」、「a」、「r」、「i」、「b」、「o」、「u」]

my_str="ellezagchickenbndodetballigatoraaaolmeznacattleeblrctacfenarcesssadlritfhftrarrssosaoiarefaareppohssarghcerumrheirmmwildfcumeboimltaairfovindalbiglalobehoeasiaxuesabldinbbccrhhrtylrlahsifdlogkrctlaiareogoldfinchefnnddmneepoletnarntadodinosauroxofoeclictnahpelepalgaierhohcaorkcocyatrmoacrflamingoerefafloechateehchdracaribou"
def create_2d_list(N):
    output_list=[]
    counter=0
    for row in range(0,N):
        temp=[]
        for col in range(0,N):
            temp.append(my_str[counter])#you can add a charcter instead of counter
            counter=counter+1
        output_list.append(temp[:])
    return output_list

N=18

x=create_2d_list(N)

for row in range(0,N):
total=0
s="|"
for col in range(0,N):
    my_str="{0:2} ".format(x[row][col])
    s=s+my_str+"|"

    print "-"*(N*4+1)
   print s,
   print " "

the_valid_words=open("E:/asd/words.txt","r").readlines()

def list_duplicates_of(seq,item):
start_at = -1
locs = []
while True:
    try:
        loc = seq.index(item,start_at+1)
    except ValueError:
        break
    else:
        locs.append(loc)
        start_at = loc
return locs

def looking_word_left_to_right(the_list):
for any_words in the_valid_words:
    for every in the_list:

        for letters_s in every:
            index_list=0
4

1 に答える 1