このコードを実行すると、次の行の:記号に構文エラーが表示されます==> if(total_size!=((len(fleet_grid)* len(fleet_grid [0 ]) - TOTAL_SIZE)):ifステートメントの末尾に構文エラーがあります
なぜそれがある
def validate_character_count(fleet_grid, ship_characters, ship_sizes):
"""(list of list of str, list of str, list of int) -> bool
Checks that the fleet on the grid matches the character and size description
"""
validity = True
total_size = 0
for size in ship_sizes:
total_size += int(size)
for row in fleet_grid:
for position in row:
if not (position.isnumeric() and position.isalpha()):
total_size += 1
if (total_size != ((len(fleet_grid)*len(fleet_grid[0])-total_size)):
validity = False
はい、あなたの括弧が一致しないためです。エラーはあなたにそれを伝えていませんでしたか? – stark