0

私が見る限り、コードが正しく、明らかなエラーがないため、エラーの原因を特定できません。

コード:

if grid_list[grid_list.index(ant_position)][0] == 1 or grid_list[grid_list.index(ant_position)][1] == 1:
    print("boom")
    if grid_list[grid_list.index(ant_position)][1] ==1 and grid_list[grid_list.index(ant_position)][0] == 1:
        print("1,1")
    else:
        if grid_list[grid_list.index(ant_position)][1] == grid_size or grid_list[grid_list.index(ant_position)][0] == grid_size:
            if grid_list[grid_list.index(ant_position)][0] == grid_size:
                print("gridsize,1")
            else:
                print("1,gridsize")
        else:
            if grid_list[grid_list.index(ant_position)][0] == 1:
                print("1,something")
            else:
                print("something,1")
else:
    if grid_list[grid_list.index(ant_position)[0] == grid_size or grid_list[grid_list.index(ant_position)][1] == grid_size:
        print("boom")
        if grid_list[grid_list.index(ant_position)][1] == grid_size and grid_list[grid_list.index(ant_position)][0] == grid_size:
            print("gridsize,gridsize")
        else:
            if grid_list[grid_list.index(ant_position)][0] == grid_size:
                print("gridsize,something")
            else:
                print("something,gridsize")
    else:       
    print("boo")

エラーは if 文の最後のコロンの print("gridsize,gridsize") のすぐ上の行で発生していると思われます。何が問題なのかわかりません。どんな助けでも感謝します。

4

1 に答える 1