in my tetris project the grid is stored as a list with 200 items that are either 0, 1 or 2 (empty tile, full tile and full tile in control of the player respectively) now what i need to do is print all the items in the list so that the result would be this:
<!. . . . . . . . . . !> 0
<!. . . . . . . . . . !> 10
...
<!. . . . . . . . . . !> 190
so on for 20 rows
the numbers on the side of the lines are the tenths of the tile indexes of said lines.
(". " if its 0 and "[]" if its 1 or 2)
the way i did this is:
tile_options = [". ", "[]"]
for i in range(len(grid)):
m = i % 10
if grid[i] == 0:
tile_state = tile_options[0]
else:
tile_state = tile_options[1]
if m == 0:
print("<!", tile_state,sep='', end='')
elif m == 9:
print(tile_state, "!> ", i // 10*10,sep='')
else:
print(tile_state,sep='',end='')
is there an easier/more optimal way to do this?
